---
- name: Add Fedora package repositories
  loop: "{{ faf_repos }}"
  shell: >
    faf repoadd --nogpgcheck "{{ item.name }}" dnf "{{ item.url | join('" "') }}"
  become: yes
  become_user: faf
  register: result
  failed_when: result.rc != 0 and 'already defined' not in result.stderr
  tags: add_repo

- name: Assign repositories to Fedora releases
  loop: "{{ faf_repos }}"
  command: "faf repoassign '{{ item.name }}' '{{ item.opsys }}' '{{ item.arch }}'"
  become: yes
  become_user: faf
  tags: add_repo

- name: List repositories of EOL Fedora releases
  loop: "{{ rs_internal_fedora_vers_removed }}"
  shell: "faf repolist | grep fedora-{{ item }} || true"
  become: yes
  become_user: faf
  register: eol_repolist
  changed_when: eol_repolist.stdout

- name: Remove repositories of EOL Fedora releases
  loop: "{{ eol_repolist.results | map(attribute='stdout_lines') | flatten }}"
  command: "faf repodel '{{ item }}'"
  become: yes
  become_user: faf
  ignore_errors: yes

- name: Clean up packages from EOL Fedora releases
  loop: "{{ rs_internal_fedora_vers_removed }}"
  command: "faf cleanup-packages Fedora '{{ item }}'"
  become: yes
  become_user: faf
  ignore_errors: yes
...
