Enable epel repository only when needed

The epel repository is used only when we need to build a debian-based
IPA image, so we enable it only in that case for CentOS Stream 8/9.

The configuration procedure is explained in the official guide [1].

[1] https://docs.fedoraproject.org/en-US/epel/#_el9

Change-Id: I57513883c0fa8d6ffb2c70debb81d5e7e6d8b221
This commit is contained in:
Riccardo Pittau 2022-01-26 11:51:00 +01:00
parent 9c2a1790fc
commit f2825ad1d9
5 changed files with 41 additions and 14 deletions

View File

@ -1,6 +1,3 @@
# NOTE(rpittau): the EPEL repository for centos 9 stream should be
# epel-next but it's not ready yet
epel-release [platform:centos-8 platform:rhel-8]
gcc
git
libffi-devel [platform:redhat platform:suse]

View File

@ -28,6 +28,7 @@ create_image_via_dib: "{{ not use_cirros | default(false) | bool }}"
create_ipa_image: false
dib_image_type: vm
dib_os_element: "debian"
enable_epel: "{{ install_dib | bool }}"
# Setting to install diskimage-builder
install_dib: "{{ create_image_via_dib | bool or create_ipa_image | bool }}"
ironic_debug: true

View File

@ -17,6 +17,26 @@
apt: update_cache=yes
when: ansible_os_family == 'Debian'
- block:
- name: "Enable powertools repository for CentOS Stream 8"
command: dnf config-manager --set-enabled powertools
- name: "Enable EPEL repository for CentOS Stream 8"
command: dnf install -y epel-release
when:
- enable_epel | bool
- dib_os_element == "debian"
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version|int == 8
- name: "Enable EPEL repository for CentOS Stream 9"
command: dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
when:
- enable_epel | bool
- dib_os_element == "debian"
- ansible_distribution == "CentOS"
- ansible_distribution_version|int >= 9
- name: "Install packages"
package:
name: "{{ required_packages }}"
@ -57,7 +77,18 @@
package:
name: "{{ dib_host_required_packages | select | list }}"
state: present
when: install_dib | bool
when:
- install_dib | bool
- ansible_distribution != "CentOS"
- name: Ensure required packages are installed
dnf:
name: "{{ dib_host_required_packages | select | list }}"
enablerepo: epel
state: present
when:
- install_dib | bool
- ansible_distribution == "CentOS"
- name: "sushy - Install"
include_role:

View File

@ -0,0 +1,8 @@
---
features:
- |
Add a boolean variable ``enable_epel`` that allows to enable the epel
repository for CentOS Stream 8/9. Since we need that only when
building a debian-based IPA image, the default value is set to
``install_dib`` and its installation depends on the value of the
dib_os_element used.

View File

@ -97,16 +97,6 @@ elif [ ${BUILD_IMAGE} = "true" ]; then
DOWNLOAD_IPA=false
CREATE_IPA_IMAGE=true
# if running in OpenStack CI, then make sure epel is enabled
# since it may already be present (but disabled) on the host
# we need epel for debootstrap
if env | grep -q ^ZUUL; then
if [[ "$OS_DISTRO" == "rhel" ]] || [[ "$OS_DISTRO" == "centos" ]]; then
sudo dnf install -y dnf-utils
sudo dnf install -y epel-release || true
sudo dnf config-manager --set-enabled epel || true
fi
fi
elif [ ${ENABLE_KEYSTONE} = "true" ]; then
NOAUTH_MODE=false
CLOUD_CONFIG+=" -e cloud_name=bifrost"