---
# Tasks specific for RedHat systems

- name: "RedHat | Make sure old file is absent"
  ansible.builtin.file:
    path: /etc/yum.repos.d/zabbix-supported.repo
    state: absent
  become: true
  tags:
    - install

- name: "RedHat | Install GPG key"
  ansible.builtin.rpm_key:
    state: present
    key: "{{ zabbix_repo_rpm_gpg_key_url }}"
  become: true
  tags:
    - install

- name: "RedHat | Install basic repo file"
  ansible.builtin.yum_repository:
    name: "{{ item.name }}"
    description: "{{ item.description }}"
    baseurl: "{{ item.baseurl }}"
    gpgcheck: "{{ item.gpgcheck | default(omit) }}"
    gpgkey: "{{ item.gpgkey }}"
    mode: "{{ item.mode | default('0644') }}"
    priority: "{{ item.priority | default('99') }}"
    state: "{{ item.state | default('present') }}"
    proxy: "{{ zabbix_http_proxy | default(omit) }}"
    username: "{{ item.username | default(omit) }}"
    password: "{{ item.password | default(omit) }}"
    sslverify: "{{ item.sslverify  | default('true') }}"
  with_items: "{{ zabbix_repo_yum }}"
  register: yum_repo_installed
  become: true
  notify:
    - "clean repo files from proxy creds"
  tags:
    - install
