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

Commit

Permalink
Install epel-release from the internet
Browse files Browse the repository at this point in the history
after trying epel-release already in the yum repos.

Also provide users with a way of disabling installing epel.

Fixes: #5558
Add ansible-pulp logic to grab epel-release from the internet
https://pulp.plan.io/issues/5558
  • Loading branch information
mikedep333 committed Oct 8, 2019
1 parent 18d67bc commit a9f2822
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
11 changes: 10 additions & 1 deletion roles/pulp/README.md
Expand Up @@ -7,7 +7,6 @@ The default administrative user for the Pulp application is: 'admin'

Role Variables:
---------------

* `pulp_cache_dir`: Location of Pulp cache. Defaults to "/var/lib/pulp/tmp".
* `pulp_config_dir`: Directory which will contain Pulp configuration files.
Defaults to "/etc/pulp".
Expand Down Expand Up @@ -46,6 +45,16 @@ Role Variables:
docs](https://docs.pulpproject.org/en/3.0/nightly/installation/configuration.html#id2) for
documentation on the possible values.
* `pulp_settings.secret_key`: **Required**. Pulp's Django application `SECRET_KEY`.
* `epel_release_packages`: List of strings (package names, URLs) to pass to
`yum install` to ensure that "epel-release" is installed.
Once the 1st string is found to be installed by yum, no further strings are
attempted.
Defaults to (on el7 for example): ["epel-release", "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"]
Set to an empty list `[]` if you wish to disable trying to install
epel-release, such as if you manually add the EPEL repo via your own
configuration or subscription-manager/katello.
Also accepts a single string or empty string.
Only affects CentOS/RHEL.
* `rhel7_optional_repo`: List of possible names for the rhel7 optional repo
to enable. Once the 1st name is enabled (or found to already be enabled),
no further names are attempted.
Expand Down
3 changes: 3 additions & 0 deletions roles/pulp/defaults/main.yml
Expand Up @@ -19,3 +19,6 @@ rhel7_optional_repo:
- rhui-rhel-7-server-rhui-optional-rpms
- rhel-7-server-optional-rpms
- rhel-7-workstation-optional-rpms
epel_release_packages:
- epel-release
- "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
2 changes: 1 addition & 1 deletion roles/pulp/meta/main.yml
Expand Up @@ -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: Debian
versions:
Expand Down
25 changes: 22 additions & 3 deletions roles/pulp/tasks/install.yml
Expand Up @@ -8,11 +8,30 @@
# 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')
# 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]
- ( ansible_loop.last ) and (epel.rc == 126)
# Cast a single string as a list.
loop: "{{ lookup('vars', 'epel_release_packages', wantlist=True) }}"
loop_control:
extended: True

- name: Install prerequisites
package:
Expand Down

0 comments on commit a9f2822

Please sign in to comment.