---

# Load distribution specific variables
- include_vars: "{{ item }}"
  with_first_found:
    - "{{ role_path }}/vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
    - "{{ role_path }}/vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml"
    - "{{ role_path }}/vars/{{ ansible_distribution }}.yml"
    - "{{ role_path }}/vars/{{ ansible_os_family }}.yml"
  tags: squashtm

# Detect installed version (if any)
- block:
    - import_tasks: ../includes/webapps_set_install_mode.yml
      vars:
        - root_dir: "{{ squashtm_root_dir }}"
        - version: "{{ squashtm_version }}"
    - set_fact: squashtm_install_mode={{ (install_mode == 'upgrade' and not squashtm_manage_upgrade) | ternary('none',install_mode) }}
    - set_fact: squashtm_current_version={{ current_version | default('') }}
  tags: squashtm

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

# Create a random pass to encrypt credentials in the database
- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{ squashtm_root_dir }}/meta/ansible_secret"
    - set_fact: squashtm_secret={{ rand_pass }}
  when: squashtm_secret is not defined
  tags: squashtm

