From b37a1e27cb746b164574355013f4139e4b154119 Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Thu, 22 Feb 2018 21:54:52 -0600 Subject: [PATCH] Fix for passing user defined value for satellite cert for rhel-common. For 'satellite' mode of registration, rpm for rhel SSL certificate is hard coded to 'katello-ca-consumer-latest.noarch.rpm'. This commit adds functionality that provides an option to set this as defined in their satellite server. Change-Id: Ib176cfa209f5ac8a4b5da71419327b4237330904 Closes-Bug: 1749947 --- diskimage_builder/elements/rhel-common/README.rst | 4 ++++ .../os-refresh-config/pre-configure.d/06-rhel-registration | 4 +++- .../elements/rhel-common/pre-install.d/00-rhel-registration | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/elements/rhel-common/README.rst b/diskimage_builder/elements/rhel-common/README.rst index a6b95ed98..f493cd446 100644 --- a/diskimage_builder/elements/rhel-common/README.rst +++ b/diskimage_builder/elements/rhel-common/README.rst @@ -210,6 +210,10 @@ Heat metadata can be used to configure the rhel-common element. # system with the Red Hat Customer Portal. Use "satellite" to # register a system with Red Hat Satellite 6. Use "disable" to # skip the registration process. + satellite_cert: + # Defines the ssl certificate to be installed when using "satellite" + # as register mechanism. Default values of this is + # "katello-ca-consumer-latest.noarch.rpm". Configuration Registration Examples ------------------------------------ diff --git a/diskimage_builder/elements/rhel-common/os-refresh-config/pre-configure.d/06-rhel-registration b/diskimage_builder/elements/rhel-common/os-refresh-config/pre-configure.d/06-rhel-registration index 851aa08e6..83f394882 100755 --- a/diskimage_builder/elements/rhel-common/os-refresh-config/pre-configure.d/06-rhel-registration +++ b/diskimage_builder/elements/rhel-common/os-refresh-config/pre-configure.d/06-rhel-registration @@ -23,6 +23,7 @@ REG_POOL_ID="$(os-apply-config --key rh_registration.poolid --type raw --key-def REG_RELEASE="$(os-apply-config --key rh_registration.release --type raw --key-default '')" REG_REPOS="$(os-apply-config --key rh_registration.repos --type raw --key-default '')" REG_SAT_URL="$(os-apply-config --key rh_registration.satellite_url --type raw --key-default '')" +REG_SAT_CERT="$(os-apply-config --key rh_registration.satellite_cert --type raw --key-default '')" REG_SERVER_URL="$(os-apply-config --key rh_registration.server_url --type raw --key-default '')" REG_SERVICE_LEVEL="$(os-apply-config --key rh_registration.service_level --type raw --key-default '')" REG_USER="$(os-apply-config --key rh_registration.user --type raw --key-default '')" @@ -33,6 +34,7 @@ opts= attach_opts= repos="repos --enable rhel-7-server-rpms" satellite_repo="rhel-7-server-rh-common-rpms" +REG_SAT_CERT=${REG_SAT_CERT:-"katello-ca-consumer-latest.noarch.rpm"} if [ -n "${REG_AUTO_ATTACH:-}" ]; then opts="$opts --auto-attach" @@ -128,7 +130,7 @@ case "${REG_METHOD:-}" in user_repos=$repos repos="$repos --enable ${satellite_repo}" echo "Installing satellite dependencies" - rpm -Uvh "$REG_SAT_URL/pub/katello-ca-consumer-latest.noarch.rpm" || true + rpm -Uvh "$REG_SAT_URL/pub/$REG_SAT_CERT" || true echo "Registering with options: $sanitized_opts" subscription-manager register $opts echo "Disabling all previous repos" diff --git a/diskimage_builder/elements/rhel-common/pre-install.d/00-rhel-registration b/diskimage_builder/elements/rhel-common/pre-install.d/00-rhel-registration index a21ef041c..b9a3f29bb 100755 --- a/diskimage_builder/elements/rhel-common/pre-install.d/00-rhel-registration +++ b/diskimage_builder/elements/rhel-common/pre-install.d/00-rhel-registration @@ -11,6 +11,7 @@ opts= attach_opts= repos="repos --enable rhel-7-server-rpms" satellite_repo="rhel-7-server-rh-common-rpms" +REG_SAT_CERT=${REG_SAT_CERT:-"katello-ca-consumer-latest.noarch.rpm"} if [ -n "${REG_AUTO_ATTACH:-}" ]; then opts="$opts --auto-attach" @@ -107,7 +108,7 @@ case "${REG_METHOD:-}" in user_repos=$repos repos="$repos --enable ${satellite_repo}" echo "Installing satellite dependencies" - rpm -Uvh "$REG_SAT_URL/pub/katello-ca-consumer-latest.noarch.rpm" || true + rpm -Uvh "$REG_SAT_URL/pub/$REG_SAT_CERT" || true echo "Registering with options: $sanitized_opts" subscription-manager register $opts echo "Disabling all previous repos"