---

- name: Configure Zabbix repo
  yum_repository:
    name: zabbix
    description: Zabbix Repository
    baseurl: http://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/rhel/$releasever/$basearch/
    gpgcheck: True
    gpgkey: "{{ zabbix_repo_key }}"
    priority: 50
    includepkgs:
      - zabbix*
  tags: repo,zabbix

- name: Configure Zabbix Agent2 plugins repo
  yum_repository:
    name: zabbix-agent2-plugins
    description: Zabbix Agent2 plugins Repository
    baseurl: http://repo.zabbix.com/zabbix-agent2-plugins/1/rhel/$releasever/$basearch/
    gpgcheck: True
    gpgkey: "{{ zabbix_plugin_key }}"
    priority: 50
    includepkgs:
      - zabbix*
  tags: repo,zabbix

- name: Configure Zabbix frontend repo
  yum_repository:
    name: zabbix-frontend
    description: Zabbix web frontend repository
    file: zabbix
    baseurl: http://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/rhel/$releasever/$basearch/frontend
    gpgcheck: True
    gpgkey: "{{ zabbix_repo_key }}"
    priority: 50
    includepkgs:
      - zabbix*
    state: "{{ (zabbix_major_version is version('5.0', '>=') and zabbix_major_version is version('5.4', '<') and ansible_distribution_major_version is version('8', '<')) | ternary('present', 'absent') }}"
  tags: repo,zabbix

