---

# All tasks about variables management

- name: 'INIT | VARIABLES | Check if OS family vars file exists'
  become: false
  ansible.builtin.stat:
    path: "{{ role_path }}/vars/os_family/{{ ansible_os_family | lower }}.yml"
  register: 'fail2ban_check_os_family_vars'
  delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Check if OS distribution vars file exists'
  become: false
  ansible.builtin.stat:
    path: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}.yml"
  register: 'fail2ban_check_os_distribution_vars'
  delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Check if OS release vars file exists'
  become: false
  ansible.builtin.stat:
    path: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.yml"
  register: 'fail2ban_check_os_release_vars'
  delegate_to: '127.0.0.1'


- name: 'INIT | VARIABLES | Load OS family vars file'
  ansible.builtin.include_vars: "{{ role_path }}/vars/os_family/{{ ansible_os_family | lower }}.yml"
  when: "fail2ban_check_os_family_vars.stat.exists"


- name: 'INIT | VARIABLES | Load OS distribution vars file'
  ansible.builtin.include_vars: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}.yml"
  when: "fail2ban_check_os_distribution_vars.stat.exists"


- name: 'INIT | VARIABLES | Load OS release vars file'
  ansible.builtin.include_vars: "{{ role_path }}/vars/os_distribution/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.yml"
  when: "fail2ban_check_os_release_vars.stat.exists"
