---

- when:
  - not openshift_is_atomic | bool
  - r_openshift_excluder_install_ran is not defined

  block:

  - name: Install docker excluder - yum
    package:
      name: "{{ r_openshift_excluder_service_type }}-docker-excluder{{ openshift_pkg_version | default('') | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) +  '*' }}"
      state: "{{ r_openshift_excluder_docker_package_state }}"
    when:
    - r_openshift_excluder_enable_docker_excluder | bool
    - ansible_pkg_mgr == "yum"
    register: result
    until: result is succeeded


  # For DNF we do not need the "*" and if we add it, it causes an error because
  # it's not a valid pkg_spec
  #
  # https://bugzilla.redhat.com/show_bug.cgi?id=1199432
  - name: Install docker excluder - dnf
    package:
      name: "{{ r_openshift_excluder_service_type }}-docker-excluder{{ openshift_pkg_version | default('') | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
      state: "{{ r_openshift_excluder_docker_package_state }}"
    when:
    - r_openshift_excluder_enable_docker_excluder | bool
    - ansible_pkg_mgr == "dnf"
    register: result
    until: result is succeeded

  - name: Install openshift excluder - yum
    package:
      name: "{{ r_openshift_excluder_service_type }}-excluder{{ openshift_pkg_version | default('') | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) + '*' }}"
      state: "{{ r_openshift_excluder_package_state }}"
    when:
    - r_openshift_excluder_enable_openshift_excluder | bool
    - ansible_pkg_mgr == "yum"
    register: result
    until: result is succeeded

  # For DNF we do not need the "*" and if we add it, it causes an error because
  # it's not a valid pkg_spec
  #
  # https://bugzilla.redhat.com/show_bug.cgi?id=1199432
  - name: Install openshift excluder - dnf
    package:
      name: "{{ r_openshift_excluder_service_type }}-excluder{{ openshift_pkg_version | default('') | lib_utils_oo_image_tag_to_rpm_version(include_dash=True) }}"
      state: "{{ r_openshift_excluder_package_state }}"
    when:
    - r_openshift_excluder_enable_openshift_excluder | bool
    - ansible_pkg_mgr == "dnf"
    register: result
    until: result is succeeded

  - set_fact:
      r_openshift_excluder_install_ran: True
