---

- include_vars: "{{ item }}"
  with_first_found:
    - vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml
    - vars/{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml
    - vars/{{ ansible_distribution }}.yml
    - vars/{{ ansible_os_family }}.yml
  tags: zabbix

- name: Check if agent is installed
  stat: path=/lib/systemd/system/zabbix-agent.service
  register: zabbix_agent_installed
  tags: zabbix

- name: Check if agent2 is installed
  stat: path=/lib/systemd/system/zabbix-agent2.service
  register: zabbix_agent2_installed
  tags: zabbix

# zabbix-agent2 is only supported on Debian >= 9
- name: Disable agent2 on older Debian
  set_fact: zabbix_agent2=False
  when: ansible_os_family == 'Debian' and ansible_distribution_major_version is version('9', '<')
  tags: zabbix
