---

- set_fact:
    base_repos:
      - name: baseos
        file: almalinux
        dir: BaseOS
      - name: appstream
        file: almalinux
        dir: AppStream
      - name: crb
        file: almalinux
        dir: CRB
      - name: extras
        file: almalinux
        dir: extras
  tags: repo

- name: Configure repositories
  yum_repository:
    file: "{{ item.file }}"
    description: "AlmaLinux {{ item.name }}"
    name: "{{ item.name }}"
    baseurl: https://repo.almalinux.org/almalinux/$releasever/{{ item.dir }}/$basearch/os/
    gpgcheck: True
    gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9
    enabled: "{{ item.enabled | default(True) }}"
  loop: "{{ base_repos }}"
  tags: repo

- name: Empty default file
  yum_repository:
    file: almalinux-{{ item.name }}
    name: "{{ item.name }}"
    state: absent
  loop: "{{ base_repos }}"
  tags: repo

- name: Configure COPR for FusionInventory
  yum_repository:
    name: fusioninventory
    description: Copr repo for FusionInventory
    file: fusioninventory
    baseurl: https://download.copr.fedorainfracloud.org/results/frsoftware/FusionInventory/epel-$releasever-$basearch/
    gpgcheck: True
    gpgkey: https://download.copr.fedorainfracloud.org/results/frsoftware/FusionInventory/pubkey.gpg
  tags: repo

- include_tasks: epel_{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml
  tags: always

- include_tasks: dbd_{{ ansible_os_family }}.yml
  tags: always

- include_tasks: postgres_client_{{ ansible_os_family }}.yml
  tags: always

