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

Commit

Permalink
Add support for CentOS 8 & RHEL8 to the ansible-pulp installer
Browse files Browse the repository at this point in the history
Implementation Includes:
- Using first_found lookup plugin to find the most relevant vars file
- Falling back to or using ansible_os_family for some tasks
  (to partially support derivative distros like Scientific Linux 7)
- Using certain python 3.6 packages from Fedora 28 until packaged in EPEL8
- Not attempting to install jneettop on CentOS 8 until packaged in EPEL8
- Adding the RHEL Codeready Builder repo on RHEL8, and PowerTools on CentOS 8

fixes: #6259
  • Loading branch information
mikedep333 committed Mar 6, 2020
1 parent 56cdde3 commit 2767bb3
Show file tree
Hide file tree
Showing 22 changed files with 230 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
.tox
**/*.pyc
/roles/geerlingguy.postgresql
/roles/pulp.pulp_rpm_prerequisites

# Ignores for Vagrant related items
.vagrant/
Expand Down
12 changes: 9 additions & 3 deletions roles/pulp-database/tasks/install_postgres.yml
Expand Up @@ -4,19 +4,25 @@
package:
name: 'centos-release-scl'
state: present
when: ansible_distribution == 'CentOS'
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version|int == 7

- name: Install PostgreSQL SCL
package:
name: 'rh-postgresql96'
state: present
when: ansible_distribution == 'CentOS'
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version|int == 7

- name: Enable PostgreSQL SCL
template:
src: templates/postgresql_scl_profile.j2
dest: "{{ postgresql_profile_path }}"
when: ansible_distribution == 'CentOS'
when:
- ansible_distribution == 'CentOS'
- ansible_distribution_major_version|int == 7

- name: Set listen addresses
set_fact:
Expand Down
11 changes: 10 additions & 1 deletion roles/pulp-database/tasks/main.yml
@@ -1,6 +1,15 @@
---
- name: Load OS specific variables
include_vars: '{{ ansible_distribution }}.yml'
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
paths:
- 'vars'
tags:
- always

Expand Down
1 change: 1 addition & 0 deletions roles/pulp-database/vars/CentOS-7.yml
1 change: 1 addition & 0 deletions roles/pulp-database/vars/CentOS-8.yml
File renamed without changes.
1 change: 1 addition & 0 deletions roles/pulp-database/vars/RedHat-8.yml
1 change: 0 additions & 1 deletion roles/pulp-database/vars/RedHat.yml

This file was deleted.

50 changes: 47 additions & 3 deletions roles/pulp-devel/tasks/install_basic_packages.yml
Expand Up @@ -6,7 +6,6 @@
- git
- htop
- iotop
- jnettop
- jq
- ncdu
- tmux
Expand All @@ -20,16 +19,59 @@
register: result
until: result is succeeded

- name: Install Centos Specific Packages
- name: Install several useful packages (CentOS 7 specific)
package:
name:
- nc
- python-virtualenvwrapper
- ruby-devel
- jnettop
- fd-find
- fzf
state: present
retries: "{{ pulp_devel_package_retries }}"
register: result
until: result is succeeded
when:
- (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat')
- ansible_distribution_major_version|int == 7

- name: Install several useful packages (CentOS 8 specific)
package:
name:
- bash-completion
- dnf-utils
- nc
- python-django-bash-completion
- python3-setuptools
- vim-enhanced
- ruby-devel
# Until packaged for EPEL8
- "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/\
28/Everything/x86_64/os/Packages/p/\
python3-virtualenvwrapper-4.8.2-4.fc28.noarch.rpm"
- "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/\
28/Everything/x86_64/os/Packages/p/\
python3-virtualenv-clone-0.2.6-9.fc28.noarch.rpm"
- "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/\
28/Everything/x86_64/os/Packages/p/\
python3-stevedore-1.25.0-2.fc28.noarch.rpm"
state: present
retries: "{{ pulp_devel_package_retries }}"
register: result
until: result is succeeded
when: ansible_distribution == 'CentOS'
when:
- (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat')
- ansible_distribution_major_version|int == 8

- name: Create virtualenvwrapper symlink
file:
src: /usr/bin/virtualenvwrapper-3.sh
dest: /usr/bin/virtualenvwrapper.sh
state: link
when:
- (ansible_distribution == 'CentOS') or (ansible_distribution == 'RedHat')
- ansible_distribution_major_version|int == 8

- name: Install several useful packages (Debian-specific)
package:
Expand All @@ -44,6 +86,7 @@
- vim
- software-properties-common
- ruby-dev
- jnettop
state: present
retries: "{{ pulp_devel_package_retries }}"
register: result
Expand All @@ -64,6 +107,7 @@
- ripgrep
- vim-enhanced
- ruby-devel
- jnettop
state: present
retries: "{{ pulp_devel_package_retries }}"
register: result
Expand Down
8 changes: 5 additions & 3 deletions roles/pulp-devel/tasks/install_podman.yml
Expand Up @@ -38,10 +38,12 @@
- ansible_distribution == 'Debian'
- ansible_virtualization_type != 'docker'

# Needed to allow non-root users to run podman containers on CentOS
- name: Set max_user_namespaces (CentOS specific)
# Needed to allow non-root users to run podman containers on EL7
- name: Set max_user_namespaces (EL7 specific)
sysctl:
name: user.max_user_namespaces
value: "15000"
when: ansible_distribution == 'CentOS'
when:
- ansible_os_family == 'RedHat'
- ansible_distribution_major_version |int == 7
...
11 changes: 10 additions & 1 deletion roles/pulp-redis/tasks/main.yml
@@ -1,6 +1,15 @@
---
- name: Load OS specific variables
include_vars: '{{ ansible_distribution }}.yml'
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
paths:
- 'vars'
tags:
- always

Expand Down
12 changes: 10 additions & 2 deletions roles/pulp-webserver/tasks/main.yml
@@ -1,7 +1,15 @@
---

- name: Load OS specific variables
include_vars: '{{ ansible_distribution }}.yml'
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
paths:
- 'vars'
tags:
- always

Expand Down
3 changes: 3 additions & 0 deletions roles/pulp/defaults/main.yml
Expand Up @@ -34,6 +34,9 @@ pulp_pip_editable: yes
pulp_use_system_wide_pkgs: false
pulp_api_bind: '127.0.0.1:24817'
prereq_pip_packages: []
pulp_rhel_codeready_repo:
- codeready-builder-for-rhel-8-x86_64-rpms
- rhui-codeready-builder-for-rhel-8-rhui-rpms
rhel7_optional_repo:
- rhui-rhel-7-server-rhui-optional-rpms
- rhel-7-server-optional-rpms
Expand Down
@@ -1,18 +1,18 @@
---
- name: Determine which in /etc/yum.repos.d/ has the repo
- name: "Determine which file in /etc/yum.repos.d/ has the {{ item }} repo"
shell: grep -l -E "^\[{{ item }}\]" /etc/yum.repos.d/*.repo
register: repo_file
changed_when: false
failed_when: false
check_mode: False

- name: Enable the repo
- name: "Enable the {{ item }} repo"
ini_file:
path: "{{ repo_file.stdout }}"
section: "{{ item }}"
option: enabled
value: 1
value: "1"
no_extra_spaces: true
when: repo_file.rc == 0
register: optional_repo_enabled
register: ambiguously_named_repo_enabled
become: true
29 changes: 0 additions & 29 deletions roles/pulp/tasks/install.yml
Expand Up @@ -8,35 +8,6 @@
# 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 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
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 | 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.
loop: "{{ lookup('vars', 'epel_release_packages', wantlist=True) | flatten }}"
loop_control:
extended: True

- name: Install prerequisites
package:
name: '{{ pulp_preq_packages }}'
Expand Down
27 changes: 11 additions & 16 deletions roles/pulp/tasks/main.yml
Expand Up @@ -5,7 +5,16 @@
that: pulp_settings.secret_key is defined

- name: Load OS specific variables
include_vars: '{{ ansible_distribution }}.yml'
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_os_family }}.yml'
paths:
- 'vars'
tags:
- always

Expand All @@ -27,21 +36,7 @@
- name: set the default system PATH as a fact
set_fact:
default_bin_path: "{{ systemd_show_env_path.stdout }}"


# 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: repos.yml
- import_tasks: install.yml
- import_tasks: configure.yml
- import_tasks: wsgi.yml

0 comments on commit 2767bb3

Please sign in to comment.