---
- name: Check if the COPR support packages should be installed
  set_fact:
    install_copr: true
  loop: "{{ _storage_copr_packages | default([]) }}"
  loop_control:
    loop_var: repo
  when:
    - _storage_copr_packages is defined
    - copr_packages is defined
    - repo.packages | intersect(copr_packages) | length > 0

- name: Make sure COPR support packages are present
  package:
    name: "{{ _storage_copr_support_packages }}"
    use: "{{ (__storage_is_ostree | d(false)) |
             ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
  when: install_copr | d(false) | bool

- name: Enable COPRs
  include_tasks: enable_copr.yml
  loop: "{{ _storage_copr_packages | default([]) }}"
  loop_control:
    loop_var: repo
  when:
    - _storage_copr_packages is defined
    - copr_packages is defined
    - repo.packages | intersect(copr_packages) | length > 0
