From ad70eae45b4f7354e031e1842c8d8d14317bf666 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Tue, 25 May 2021 13:31:54 +0200 Subject: [PATCH] Set module_hotfixes=true for yumrepo if Puppet >= 6.15.0 The RDO and CentOS Advanced Virt repositories contains packages that should be considered hotfixes to version found in Base repo and similar and should have priority over them. The yumrepo_core [1] change that was released in 1.0.7 adds the module_hotfixes parameter to yumrepo and it's included in Puppet >= 6.15.0 which we should set to true to make sure packages in RDO and CentOS Advanced Virt repos is considered hotfixes upon base packages. When we only support Puppet 7 and forward we should set this by default for the yumrepo resources. [1] https://github.com/puppetlabs/puppetlabs-yumrepo_core/pull/28/commits/a14c059b7d0c395ff0bdad04da48716272000637 Depends-On: https://review.opendev.org/c/792966 Change-Id: Ie747273e2ce23fadba0f3946e227ee143c1632db --- manifests/repo/redhat/redhat.pp | 18 ++++++++ ...hotfixes-redhat-repo-e03358eb341bf820.yaml | 10 +++++ ...penstack_extras_repo_redhat_redhat_spec.rb | 45 ++++++++++++------- 3 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 releasenotes/notes/set-module-hotfixes-redhat-repo-e03358eb341bf820.yaml diff --git a/manifests/repo/redhat/redhat.pp b/manifests/repo/redhat/redhat.pp index 7599fb2..12567cf 100644 --- a/manifests/repo/redhat/redhat.pp +++ b/manifests/repo/redhat/redhat.pp @@ -147,6 +147,15 @@ class openstack_extras::repo::redhat::redhat ( create_resources('file', $rdokey_hash, $_gpgkey_defaults) create_resources('yumrepo', $rdo_hash, $_repo_defaults) + + # NOTE(tobias-urdin): This was introduced in yumrepo_core 1.0.7 which is + # included from 6.15.0 and forward (also since 7.0.0). + # TODO(tobias-urdin): Should set this by default when we only support Puppet 7. + if versioncmp($::puppetversion, '6.15.0') >= 0 { + Yumrepo<| title == 'rdo-release' |> { + module_hotfixes => true, + } + } } if $manage_virt and ($facts['os']['name'] != 'Fedora') { @@ -177,6 +186,15 @@ class openstack_extras::repo::redhat::redhat ( create_resources('file', $virtkey_hash, $_gpgkey_defaults) create_resources('yumrepo', $virt_hash, $_repo_defaults) + + # NOTE(tobias-urdin): This was introduced in yumrepo_core 1.0.7 which is + # included from 6.15.0 and forward (also since 7.0.0). + # TODO(tobias-urdin): Should set this by default when we only support Puppet 7. + if versioncmp($::puppetversion, '6.15.0') >= 0 { + Yumrepo<| title == 'centos-advanced-virt' |> { + module_hotfixes => true, + } + } } if ($manage_epel and $facts['os']['name'] != 'Fedora') { diff --git a/releasenotes/notes/set-module-hotfixes-redhat-repo-e03358eb341bf820.yaml b/releasenotes/notes/set-module-hotfixes-redhat-repo-e03358eb341bf820.yaml new file mode 100644 index 0000000..57fa50d --- /dev/null +++ b/releasenotes/notes/set-module-hotfixes-redhat-repo-e03358eb341bf820.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + The yumrepo resources for RDO and CentOS Advanced Virt in the + openstack_extras::repo::redhat::redhat class now sets the new + parameter module_hotfixes included since 6.15.0 if the Puppet + version is supporting that. If you for some reason is using + standalone Puppet that does not include vendored modules (i.e + you are not using Puppet packages) you will need to make sure + that yumrepo_core >= 1.0.7 is used. \ No newline at end of file diff --git a/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb index 02d892d..eae6147 100644 --- a/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb +++ b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb @@ -14,14 +14,15 @@ describe 'openstack_extras::repo::redhat::redhat' do )} it { should contain_yumrepo('rdo-release').with( - :baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/cloud/$basearch/openstack-victoria/", - :descr => "OpenStack Victoria Repository", - :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud', - :enabled => '1', - :gpgcheck => '1', - :mirrorlist => 'absent', - :notify => 'Exec[yum_refresh]', - :require => 'Anchor[openstack_extras_redhat]', + :baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/cloud/$basearch/openstack-victoria/", + :descr => "OpenStack Victoria Repository", + :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Cloud', + :enabled => '1', + :gpgcheck => '1', + :mirrorlist => 'absent', + :module_hotfixes => true, + :notify => 'Exec[yum_refresh]', + :require => 'Anchor[openstack_extras_redhat]', )} it { should contain_yumrepo('rdo-qemu-ev').with_ensure('absent') } @@ -35,14 +36,15 @@ describe 'openstack_extras::repo::redhat::redhat' do )} it { should contain_yumrepo('centos-advanced-virt').with( - :baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/virt/$basearch/advancedvirt-common/", - :descr => "CentOS-#{facts[:operatingsystemmajrelease]}-stream - Advanced Virt", - :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization', - :enabled => '1', - :gpgcheck => '1', - :mirrorlist => 'absent', - :notify => 'Exec[yum_refresh]', - :require => 'Anchor[openstack_extras_redhat]', + :baseurl => "http://mirror.centos.org/centos/#{facts[:operatingsystemmajrelease]}-stream/virt/$basearch/advancedvirt-common/", + :descr => "CentOS-#{facts[:operatingsystemmajrelease]}-stream - Advanced Virt", + :gpgkey => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Virtualization', + :enabled => '1', + :gpgcheck => '1', + :mirrorlist => 'absent', + :module_hotfixes => true, + :notify => 'Exec[yum_refresh]', + :require => 'Anchor[openstack_extras_redhat]', )} it { should_not contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-#{facts[:operatingsystemmajrelease]}") } @@ -58,6 +60,17 @@ describe 'openstack_extras::repo::redhat::redhat' do it { should_not contain_exec('yum_update') } end + context 'with default parameters but puppetversion < 6.15.0' do + before do + facts.merge!( :puppetversion => '6.14.0' ) + end + + it { + should contain_yumrepo('rdo-release').without_module_hotfixes + should contain_yumrepo('centos-advanced-virt').without_module_hotfixes + } + end + context 'with parameters' do let :params do {