From 30296ad28e4898a3504cd7ec3d13923fa6104bff Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 11 May 2020 09:18:43 +0900 Subject: [PATCH] Require yum-plugin-priorities only in CentOS/RHEL<8 ... because it was merged into dnf package since CentOS/RHEL8. Change-Id: I468935b91c5dd2e06cffab26c78eff1843c207cd --- manifests/repo/redhat/redhat.pp | 22 +++++++++++-------- ...penstack_extras_repo_redhat_redhat_spec.rb | 8 +++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifests/repo/redhat/redhat.pp b/manifests/repo/redhat/redhat.pp index 0ae7cdb..5f356f3 100644 --- a/manifests/repo/redhat/redhat.pp +++ b/manifests/repo/redhat/redhat.pp @@ -93,6 +93,8 @@ class openstack_extras::repo::redhat::redhat( $_repo_defaults = merge($::openstack_extras::repo::redhat::params::repo_defaults, $repo_defaults) $_gpgkey_defaults = merge($::openstack_extras::repo::redhat::params::gpgkey_defaults, $gpgkey_defaults) + $os_major = $::os['release']['major'] + anchor { 'openstack_extras_redhat': } if $manage_rdo { @@ -116,7 +118,6 @@ class openstack_extras::repo::redhat::redhat( } if $manage_virt and ($::operatingsystem != 'Fedora') { - $os_major = $::os['release']['major'] if Integer.new($os_major) >= 8 { $virt_baseurl = "${centos_mirror_url}/centos/${os_major}/virt/\$basearch/advanced-virtualization/" @@ -172,21 +173,24 @@ class openstack_extras::repo::redhat::redhat( } if $manage_priorities and ($::operatingsystem != 'Fedora') { - exec { 'installing_yum-plugin-priorities': - command => '/usr/bin/yum install -y yum-plugin-priorities', - logoutput => 'on_failure', - tries => 3, - try_sleep => 1, - unless => '/usr/bin/rpm -qa | /usr/bin/grep -q yum-plugin-priorities', + if Integer.new($os_major) < 8 { + # yum-plugin-priorities is unavailable since RHEL/CentOS8 + exec { 'installing_yum-plugin-priorities': + command => '/usr/bin/yum install -y yum-plugin-priorities', + logoutput => 'on_failure', + tries => 3, + try_sleep => 1, + unless => '/usr/bin/rpm -qa | /usr/bin/grep -q yum-plugin-priorities', + } + Exec['installing_yum-plugin-priorities'] -> Yumrepo<||> } - Exec['installing_yum-plugin-priorities'] -> Yumrepo<||> } if $package_require { Yumrepo<||> -> Package<||> } - if ($::operatingsystem == 'Fedora') { + if ($::operatingsystem == 'Fedora') or (Integer.new($os_major) >= 8) { exec { 'yum_refresh': command => '/usr/bin/dnf clean all', refreshonly => true, diff --git a/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb index 687288e..80bdb16 100644 --- a/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb +++ b/spec/classes/openstack_extras_repo_redhat_redhat_spec.rb @@ -109,6 +109,14 @@ describe 'openstack_extras::repo::redhat::redhat' do )} end + context 'with major release 8' do + before do + facts.merge!( :os => {'release' => {'major' => 8}} ) + end + + it { should_not contain_exec('installing_yum-plugin-priorities') } + end + context 'with overridden release' do let :params do default_params.merge!({ :release => 'juno' })