Skip to content

Commit

Permalink
Cleanup repositories handling
Browse files Browse the repository at this point in the history
- Use the shared rhos-release role to deploy rhos-release.
- Use generic links to refer to the internal rhpkg repositories
  and adapt the code to deal with those repositories.
- Reorder the code which handles those repositories and consolidate
  the operations for the various versions. The usage of shared
  code and generic links reduces the distro-specific code
  and will help adding RHEL9 support.
- Also, fix the references to the testing repositories
  that are enabled during the process.

Change-Id: If6becf1c2c6b7030fe726da1f3d5c938644dccdd
  • Loading branch information
tosky committed Jun 27, 2022
1 parent 5abb2be commit 36d46fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 71 deletions.
4 changes: 3 additions & 1 deletion roles/patch_rpm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
name:
- 'rpm-build'
state: present
disablerepo: 'rhpkg'
disablerepo:
- rcm-tools-rhel-7-server-rpms
- rcm-tools-rhel-7-server-optional-rpms
register: task_result
until: task_result is success
retries: 3
Expand Down
93 changes: 23 additions & 70 deletions roles/setup_repos/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,4 @@
---
- name: RHEL8 specific preparation
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8' | default(false)
tags:
- skip_ansible_lint
block:
# Standard yum is failing
# Ansible expects dnf from python2, needs to use shell
- name: Install rhos-release - RHEL-8
become: yes
shell: |
{{ dnf_bin }} -y install http://download.devel.redhat.com/rcm-guest/puddles/OpenStack/rhos-release/rhos-release-latest.noarch.rpm
- name: Execute rhos-release for initial install of RHOS repos
become: yes
shell: "{{ rhos_release_bin }} -u"
tags:
- skip_ansible_lint

- name: Enable correct python/selinux modules for RHEL-8
become: yes
shell: |
set -euo pipefail
{{ dnf_bin }} -y module enable libselinux-python || true
{{ dnf_bin }} -y install libselinux-python
{{ dnf_bin }} -y module enable python36
{{ dnf_bin }} -y install python36
{{ alternatives_bin }} --set python /usr/bin/python3
# This task will register all repos on the system to disable each one of them
# with the second task.
- name: Register all the repositories
Expand All @@ -45,26 +17,19 @@
replace: "enabled=0"
with_items: "{{ yum_repos.stdout_lines }}"

- name: Deploy rhos-release
include_role:
name: rhos-release
vars:
release: "{{ install.component.version }}"
build: "latest"
rhos_release_rpm: "https://url.corp.redhat.com/rhos-release-latest-rpm"

- name: RHEL7 specific repositories
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == '7' | default(false)
tags:
- skip_ansible_lint
block:
- name: Install rhos-release - RHEL-7
become: yes
yum:
name: "http://download.devel.redhat.com/rcm-guest/puddles/OpenStack/rhos-release/rhos-release-latest.noarch.rpm"
register: task_result
until: task_result is success
retries: 3
delay: 3

- name: Execute rhos-release to install rhos repos
become: yes
shell: "{{ rhos_release_bin }} -x; {{ rhos_release_bin }} -P -r {{ ansible_distribution_version }} {{ install.component.version }}"
changed_when: true

- name: Enable unittest and test-deps repositories
become: yes
ini_file:
Expand All @@ -73,36 +38,23 @@
option: enabled
value: 1
with_items:
- rhelosp-{{ install.component.version | regex_replace('(^[0-9]+$)', '\\1.0') }}-unittest
- rhelosp-{{ install.component.version | regex_replace('(^[0-9]+$)', '\\1.0') }}-test-deps

- name: Install rhpkg repos for RHEL-7
become: yes
yum_repository:
name: rhpkg
description: rhpkg for Red Hat Enterprise Linux
baseurl: "http://download.devel.redhat.com/rhel-7/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-7/compose/Server/x86_64/os/"
gpgcheck: no
enabled: yes
- rhelosp-{{ install.component.version | regex_replace('(^[0-9]+$)', '\1.0') }}-unittest
- rhelosp-{{ install.component.version | regex_replace('(^[0-9]+$)', '\1.0') }}-test-deps

- name: RHEL8 specific repositories
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8' | default(false)
tags:
- skip_ansible_lint
block:
- name: Execute rhos-release to install rhos repos
become: yes
shell: "{{ rhos_release_bin }} -x; {{ rhos_release_bin }} -P -r {{ ansible_distribution_version }} {{ install.component.version }}"
changed_when: true

- name: Install rhpkg repos for RHEL-8
- name: Enable correct python/selinux modules for RHEL-8
become: yes
yum_repository:
name: rhpkg
description: rhpkg for Red Hat Enterprise Linux
baseurl: "http://download.devel.redhat.com/rhel-8/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-8/compose/BaseOS/x86_64/os/"
gpgcheck: no
enabled: yes
shell: |
set -euo pipefail
{{ dnf_bin }} -y module enable libselinux-python || true
{{ dnf_bin }} -y install libselinux-python
{{ dnf_bin }} -y module enable python36
{{ dnf_bin }} -y install python36
{{ alternatives_bin }} --set python /usr/bin/python3
- name: Enable correct Virt modules for RHEL-8
become: yes
Expand All @@ -111,11 +63,12 @@
{{ dnf_bin }} -y module disable virt
{{ dnf_bin }} -y module enable virt
- name: Install packages required for patching - workaround - RHEL-8
become: yes
shell: |
set -euo pipefail
{{ dnf_bin }} install -y http://download.devel.redhat.com/brewroot/vol/rhel-8/packages/python-distro/1.4.0/1.el8eng/noarch/python3-distro-1.4.0-1.el8eng.noarch.rpm
- name: Install rhpkg repos
become: yes
get_url:
url: https://url.corp.redhat.com/rcm-tools-el{{ ansible_distribution_major_version }}-repo
dest: /etc/yum.repos.d/rcm-tools-rhel{{ ansible_distribution_major_version }}.repo
validate_certs: no

# To satisfy rdopkg and its dependencies.
- name: Install EPEL repository
Expand Down

0 comments on commit 36d46fa

Please sign in to comment.