---

- name: Detect installed version
  block:
    - import_tasks: ../includes/webapps_set_install_mode.yml
      vars:
        - root_dir: "{{ miniflux_root_dir }}"
        - version: "{{ miniflux_version }}"
    - set_fact: miniflux_install_mode={{ (install_mode == 'upgrade' and not miniflux_manage_upgrade) | ternary('none',install_mode) }}
    - set_fact: miniflux_current_version={{ current_version | default('') }}
  tags: miniflux

- when: miniflux_db_pass is not defined
  name: Generate a random pass for the database
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ miniflux_root_dir }}/meta/ansible_dbpass"
    - set_fact: miniflux_db_pass={{ rand_pass }}
  tags: miniflux

- when: miniflux_admin_pass is not defined
  name: Generate a random pass for the admin account
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ miniflux_root_dir }}/meta/ansible_admin_pass"
    - set_fact: miniflux_admin_pass={{ rand_pass }}
  tags: miniflux
