Add ability to install kernel related packages

Added support to have the kernel class install packages prior to the
kmod loading.

Change-Id: I6085bcd2f91f84577dcf59d3c93afb24ab718a49
Related-Bug: #1840180
(cherry picked from commit cf8dc4658a)
This commit is contained in:
Alex Schultz 2019-08-14 13:27:37 -06:00
parent a27e36075a
commit c68940547e
2 changed files with 29 additions and 0 deletions

View File

@ -23,18 +23,34 @@
# (Optional) List of kernel modules to load. # (Optional) List of kernel modules to load.
# Defaults to hiera('kernel_modules') # Defaults to hiera('kernel_modules')
# #
# [*package_list*]
# (Optional) List of additional kernel related packages to load
# Defaults to hiera('kernel_packages')
#
# [*sysctl_settings*] # [*sysctl_settings*]
# (Optional) List of sysctl settings to load. # (Optional) List of sysctl settings to load.
# Defaults to hiera('sysctl_settings') # Defaults to hiera('sysctl_settings')
# #
class tripleo::profile::base::kernel ( class tripleo::profile::base::kernel (
$module_list = hiera('kernel_modules', undef), $module_list = hiera('kernel_modules', undef),
$package_list = hiera('kernel_packages', undef),
$sysctl_settings = hiera('sysctl_settings', undef), $sysctl_settings = hiera('sysctl_settings', undef),
) { ) {
if $module_list { if $module_list {
create_resources(kmod::load, $module_list, { }) create_resources(kmod::load, $module_list, { })
} }
if $package_list {
$pkg_defaults = {
'tag' => 'kernel-package'
}
create_resources(package, $package_list, $pkg_defaults)
# ensure we install the package prior to trying to load kmods to make sure
# if the package list includes a kmod that it will be available.
Package<| tag == 'kernel-package' |> -> Exec<| tag == 'kmod::load' |>
}
if $sysctl_settings { if $sysctl_settings {
create_resources(sysctl::value, $sysctl_settings, { }) create_resources(sysctl::value, $sysctl_settings, { })
} }

View File

@ -32,6 +32,19 @@ describe 'tripleo::profile::base::kernel' do
is_expected.to contain_kmod__load('nf_conntrack') is_expected.to contain_kmod__load('nf_conntrack')
end end
end end
context 'with packages' do
let :params do
{
:package_list => {
'kmod_special' => {},
}
}
end
it 'should install package' do
is_expected.to contain_package('kmod_special').with('tag' => 'kernel-package')
end
end
context 'with sysctl settings' do context 'with sysctl settings' do
let :params do let :params do
{ {