---

# Detect installed version (if any)
- block:
    - import_tasks: ../includes/webapps_set_install_mode.yml
      vars:
        - root_dir: "{{ pim_root_dir }}"
        - version: "{{ pim_version }}"
    - set_fact: pim_install_mode={{ (install_mode == 'upgrade' and not pim_manage_upgrade) | ternary('none',install_mode) }}
    - set_fact: pim_current_version={{ current_version | default('') }}
  tags: pim

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

# Create a random secret if needed
- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ pim_root_dir }}/meta/ansible_secret"
    - set_fact: pim_secret={{ rand_pass }}
  when: pim_secret is not defined
  tags: pim

# Create a random admin pass if needed
- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ pim_root_dir }}/meta/ansible_admin_pass"
    - set_fact: pim_admin_pass={{ rand_pass }}
  when: pim_admin_pass is not defined
  tags: pim
