diff --git a/manifests/plugin/versionlock.pp b/manifests/plugin/versionlock.pp index 3cd9e862..edbc746e 100644 --- a/manifests/plugin/versionlock.pp +++ b/manifests/plugin/versionlock.pp @@ -18,8 +18,14 @@ String $path = '/etc/yum/pluginconf.d/versionlock.list', Boolean $clean = false, ) { + $pkg_prefix = $facts['os']['release']['major'] ? { + Variant[Integer[5,5], Enum['5']] => 'yum', + '8' => 'python3-dnf-plugin', + default => 'yum-plugin', + } yum::plugin { 'versionlock': - ensure => $ensure, + ensure => $ensure, + pkg_prefix => $pkg_prefix, } include yum::clean diff --git a/spec/acceptance/define_versionlock_spec.rb b/spec/acceptance/define_versionlock_spec.rb index 6e83d2a7..d088fb54 100644 --- a/spec/acceptance/define_versionlock_spec.rb +++ b/spec/acceptance/define_versionlock_spec.rb @@ -43,7 +43,7 @@ end describe file('/etc/yum/pluginconf.d/versionlock.list') do it { is_expected.to be_file } - if %w[6 7].include?(fact('os.release.major')) + if %w[7].include?(fact('os.release.major')) it { is_expected.to contain '0:bash-4.1.2-9.el6_2.*' } it { is_expected.to contain '0:tcsh-3.1.2-9.el6_2.*' } it { is_expected.to contain '2:netscape-8.1.2-9.el6_2.*' } @@ -53,6 +53,15 @@ it { is_expected.to contain 'netscape-2:8.1.2-9.el6_2.*' } end end + if fact('os.release.major') == '8' + describe package('python3-dnf-plugin-versionlock') do + it { is_expected.to be_installed } + end + else + describe package('yum-plugin-versionlock') do + it { is_expected.to be_installed } + end + end end it 'must work if clean is specified' do shell('yum repolist', acceptable_exit_codes: [0]) @@ -76,10 +85,11 @@ # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) + # Check the cache is really empty. # all repos will have 0 packages. # bit confused by the motivation of the first test? - if %w[6 7].include?(fact('os.release.major')) + if fact('os.release.major') == '7' shell('yum -C repolist -d0 | grep -v "repo id" | awk "{print $NF}" FS= | grep -v 0', acceptable_exit_codes: [1]) shell('yum -q list available samba-devel', acceptable_exit_codes: [1]) else