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

Commit

Permalink
Add logic to add the RHEL7 optional repo
Browse files Browse the repository at this point in the history
From multiple possible repo names.
Stop doing any more changes once the first is found.
Let users disable this as well.

Fixes: #5557
Add ansible-pulp logic to add the RHEL7 optional repo
https://pulp.plan.io/issues/5557
  • Loading branch information
mikedep333 committed Oct 8, 2019
1 parent 1a1617a commit f0b5dd8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
9 changes: 9 additions & 0 deletions roles/pulp/README.md
Expand Up @@ -46,6 +46,15 @@ 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`.
* `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.
Defaults to ["rhui-rhel-7-server-rhui-optional-rpms", "rhel-7-server-optional-rpms", "rhel-7-workstation-optional-rpms"]
Set to an empty list `[]` if you wish to disable trying to enable the repo,
such as if you manually add the optional repo via your own configuration or
subscription-manager/katello.
Also accepts a single string or empty string.
Only affects RHEL7 (RHEL8 no longer has an optional repo.)


Shared Variables:
Expand Down
4 changes: 4 additions & 0 deletions roles/pulp/defaults/main.yml
Expand Up @@ -15,3 +15,7 @@ pulp_pip_editable: yes
pulp_use_system_wide_pkgs: false
pulp_api_bind: '127.0.0.1:24817'
prereq_pip_packages: []
rhel7_optional_repo:
- rhui-rhel-7-server-rhui-optional-rpms
- rhel-7-server-optional-rpms
- rhel-7-workstation-optional-rpms
13 changes: 13 additions & 0 deletions roles/pulp/tasks/main.yml
Expand Up @@ -28,6 +28,19 @@
set_fact:
default_bin_path: "{{ systemd_show_env_path }}"

# Try multiple possible names for the rhel7 optional repo until it is found.
# The query ensures that a single string rather than a list of strings is valid.
- include_tasks: rhel7-optional.yml
with_items: "{{ rhel7_optional_repo }}"
when:
- ansible_distribution == "RedHat"
- ansible_distribution_major_version|int == 7
# Works for both strings and lists to make sure not empty
- rhel7_optional_repo is not none
- rhel7_optional_repo | length > 0
# Prevents running again once completed.
- optional_repo_enabled is not defined

- import_tasks: install.yml
- import_tasks: configure.yml
- import_tasks: wsgi.yml
18 changes: 18 additions & 0 deletions roles/pulp/tasks/rhel7-optional.yml
@@ -0,0 +1,18 @@
---
- name: Determine which in /etc/yum.repos.d/ has the repo
command: grep -l -E "^\[{{ item }}\]" /etc/yum.repos.d/*.repo -R
register: repo_file
changed_when: false
failed_when: false
check_mode: False

- name: Enable the repo
ini_file:
path: "{{ repo_file.stdout }}"
section: "{{ item }}"
option: enabled
value: 1
no_extra_spaces: true
when: repo_file.rc == 0
register: optional_repo_enabled
become: true
1 change: 1 addition & 0 deletions roles/pulp/vars/RedHat.yml

0 comments on commit f0b5dd8

Please sign in to comment.