From 3f2a0ba13babd9c0b7d3c88346a89996404f0106 Mon Sep 17 00:00:00 2001 From: Mike DePaulo Date: Tue, 8 Oct 2019 11:15:24 -0400 Subject: [PATCH] Attempt to install epel-release from the internet after trying epel-release already in the yum repos. Fixes: #5558 Add ansible-pulp logic to grab epel-release from the internet https://pulp.plan.io/issues/5558 --- roles/pulp/meta/main.yml | 2 +- roles/pulp/tasks/install.yml | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/roles/pulp/meta/main.yml b/roles/pulp/meta/main.yml index 653bfeea5..9c7cb59a5 100644 --- a/roles/pulp/meta/main.yml +++ b/roles/pulp/meta/main.yml @@ -5,7 +5,7 @@ galaxy_info: issue_tracker_url: https://pulp.plan.io/projects/external/issues/new license: GPLv2 company: Red Hat - min_ansible_version: 2.2 + min_ansible_version: 2.8 platforms: - name: Fedora versions: diff --git a/roles/pulp/tasks/install.yml b/roles/pulp/tasks/install.yml index e9fd0b287..f1c94066a 100644 --- a/roles/pulp/tasks/install.yml +++ b/roles/pulp/tasks/install.yml @@ -8,11 +8,27 @@ # This is a lie, but necessary for Idempotence test 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. - name: Install EPEL Release - package: - name: epel-release + yum: + name: "{{ item }}" state: present - when: ansible_distribution == 'CentOS' + # dnf/yum4 registered results not implemented yet + use_backend: yum + register: epel + when: + - (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat') + - ({{ ansible_loop.first }}) or (epel.rc == 126) + failed_when: + - epel.rc not in [0,126] + - ({{ ansible_loop.last }}) and (epel.rc == 126) + loop: + - epel-release + - "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" + loop_control: + extended: True - name: Install prerequisites package: