---

- 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: wapt

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

- when: wapt_secret_key is not defined
  name: Generate a random secret_key
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "/opt/wapt/meta/ansible_secret_key"
    - set_fact: wapt_secret_key={{ rand_pass }}
  tags: wapt
