Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Implement support for installing epel8
Browse files Browse the repository at this point in the history
By replacing the overly specific loop with a more generic one.

fixes: #6260
  • Loading branch information
mikedep333 committed Mar 2, 2020
1 parent 9da56e7 commit 065c516
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions roles/pulp/tasks/install.yml
Expand Up @@ -9,24 +9,27 @@
changed_when: False

# Break the loop once the first package name/URL in the list is found to be installed.
# The yum module (which wraps the yum command) uses rc=126 for package not
# found, or 0 for changed / already installed.
# The yum module with the yum backend (which wraps the yum command) uses
# rc=126 for package not found, or 0 for changed / already installed.
# The dnf backend can have different strings for the package not being found,
# and returns a generic rc of 1.
# If the package cannot be downloaded for an https URL, no rc is present.
# So let's just keep trying until success (rc 0).
- name: Install EPEL Release
yum:
name: "{{ item }}"
state: present
# dnf/yum4 registered results not implemented yet
use_backend: yum
register: epel
when:
- (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat')
# Works for both strings and lists to make sure not empty
- epel_release_packages is defined
- epel_release_packages is not none
- epel_release_packages | length > 0
- ( ansible_loop.first ) or (epel.rc == 126)
failed_when: (epel.rc not in [0,126]) or
(( ansible_loop.last ) and (epel.rc == 126))
- ( ansible_loop.first ) or (epel.rc | default(1) != 0)
failed_when:
- ansible_loop.last
- epel.rc != 0
# Cast a single string as a list so that the loop will work.
# This will also convert a list to a list with 1 list in it, so flatten it
# so that the yum task will only operate on 1 item at a time.
Expand Down

0 comments on commit 065c516

Please sign in to comment.