---

- fail: msg="pg_admin_pass must be set"
  when: pg_admin_pass is not defined
  tags: ged

- import_tasks: ../includes/webapps_set_install_mode.yml
  vars:
    - root_dir: "{{ papermerge_root_dir }}"
    - version: "{{ papermerge_version }}"
  tags: ged

- import_tasks: ../includes/webapps_set_install_mode.yml
  vars:
    - root_dir: "{{ papermerge_root_dir }}"
    - version: "{{ papermerge_version }}"
  tags: ged

- block:
    - set_fact: papermerge_install_mode={{ (install_mode == 'upgrade' and not papermerge_manage_upgrade) | ternary('none',install_mode) }}
    - set_fact: papermerge_current_version={{ current_version | default('') }}
  tags: ged

  # Create a random pass for the DB if needed
- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ papermerge_root_dir }}/meta/ansible_dbpass"
    - set_fact: papermerge_db_pass={{ rand_pass }}
  when: papermerge_db_pass is not defined
  tags: ged

  # Create a random secret key
- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ papermerge_root_dir }}/meta/ansible_secret_key"
    - set_fact: papermerge_secret_key={{ rand_pass }}
  when: papermerge_secret_key is not defined
  tags: ged
