---

# 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: odoo

- name: Detect installed version
  block:
    - import_tasks: ../includes/webapps_set_install_mode.yml
      vars:
        - root_dir: "{{ odoo_root_dir }}"
        - version: "{{ odoo_version }}-{{ odoo_build }}"
    - set_fact: odoo_install_mode={{ install_mode | default('none') }}
    - set_fact: odoo_current_version={{ current_version | default('') }}
  tags: odoo

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