Skip to content

Commit

Permalink
Add place to seed post_transaction_actions and versionlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk committed Apr 23, 2024
1 parent a9e2192 commit 04f74c5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
# @param groups
# A hash of yum::group instances to manage.
#
# @param post_transaction_actions
# A hash of yum::post_transaction_action instances to manage
#
# @param versionlocks
# A hash of yum::versionlock instances to manage
#
# @example Enable management of the default repos for a supported OS:
# ---
# yum::manage_os_default_repos: true
Expand Down Expand Up @@ -117,6 +123,8 @@
Hash[String, Hash[String, String]] $gpgkeys = {},
String $utils_package_name = 'yum-utils',
Stdlib::CreateResources $groups = {}
Stdlib::CreateResources $post_transaction_actions = {}
Stdlib::CreateResources $versionlocks = {}
) {
$module_metadata = load_module_metadata($module_name)
$supported_operatingsystems = $module_metadata['operatingsystem_support']
Expand Down Expand Up @@ -243,4 +251,16 @@
* => $_group_attrs,
}
}

$post_transaction_actions.each |$_action, $_action_attrs| {
yum::post_transaction_action { $_action:
* => $_action_attrs,
}
}

$versionlocks.each |$_lock, $_lock_attrs| {
yum::versionlock { $_lock:
* => $_lock_attrs,
}
}
}
36 changes: 36 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
it_behaves_like 'a Yum class'
it { is_expected.to have_yumrepo_resource_count(0) }
it { is_expected.to have_yum__group_resource_count(0) }
it { is_expected.to have_yum__post_transaction_action_resource_count(0) }
it { is_expected.to have_yum__versionlock_resource_count(0) }
end

context 'with package_provider yum' do
Expand Down Expand Up @@ -830,6 +832,40 @@
it { is_expected.to contain_yum__group('Puppet Tools').with_ensure('absent') }
it { is_expected.to contain_yum__group('Dev Tools').with_ensure('installed') }
end

context 'when post_transaction_actions parameter is set' do
let(:params) do
{
post_transaction_actions: {
'touch file for ssh': {
key: 'openssh-*',
state: 'any',
command: 'touch /tmp/openssh-installed',
},
},
}
end

it { is_expected.to contain_yum__post_transaction_action('touch file for ssh').with_key('openssh-*') }
end

context 'when versionlocks parameter is set' do
let(:params) do
{
versionlocks: {
'bash':
ensure: 'present',
version: '4.1.2',
release: '9.el8',
epoch: 0,
arch: 'noarch',
},
},
}
end

it { is_expected.to contain_yum__versionlock('bash').with_ensure('present') }
end
end
end

Expand Down

0 comments on commit 04f74c5

Please sign in to comment.