Skip to content

Commit

Permalink
fix package name for yum plugin versionlock on RHEL/CentOS 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Maser committed Jun 9, 2021
1 parent ee282d8 commit 822a2e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 7 additions & 1 deletion manifests/plugin/versionlock.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions spec/acceptance/define_versionlock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.*' }
Expand All @@ -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])
Expand All @@ -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
Expand Down

0 comments on commit 822a2e2

Please sign in to comment.