Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#issue_318) Added ability for users to switch between '/bin/true' and '/bin/false' when disabling kernel modules via the kmod_blacklist class #322

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* Tue Jul 09 2024 Mike Riddle <[email protected]> - 4.22.0
- Added ability for users to switch between '/bin/true' and '/bin/false' when disabling kernel modules via the kmod_blacklist class

* Tue Jul 02 2024 Steven Pritchard <[email protected]> - 4.21.0
- Clean up use of legacy facts to better support Puppet 8

Expand Down
11 changes: 11 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ The following parameters are available in the `simp::kmod_blacklist` class:

* [`enable_defaults`](#-simp--kmod_blacklist--enable_defaults)
* [`blacklist`](#-simp--kmod_blacklist--blacklist)
* [`produce_error`](#-simp--kmod_blacklist--produce_error)
* [`custom_blacklist`](#-simp--kmod_blacklist--custom_blacklist)
* [`allow_overrides`](#-simp--kmod_blacklist--allow_overrides)
* [`lock_modules`](#-simp--kmod_blacklist--lock_modules)
Expand Down Expand Up @@ -758,6 +759,16 @@ Default value:
]
```

##### <a name="-simp--kmod_blacklist--produce_error"></a>`produce_error`

Data type: `Boolean`

If set to true, any disabled modules will point to '/bin/false', which will
produce an error when anyone attempts to load the module. Default is false,
which will point to '/bin/true', which will not produce any error.

Default value: `false`

##### <a name="-simp--kmod_blacklist--custom_blacklist"></a>`custom_blacklist`

Data type: `Array[String]`
Expand Down
13 changes: 12 additions & 1 deletion manifests/kmod_blacklist.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# @param blacklist
# List of kernel modules to be blacklisted by default
#
# @param produce_error
# If set to true, any disabled modules will point to '/bin/false', which will
# produce an error when anyone attempts to load the module. Default is false,
# which will point to '/bin/true', which will not produce any error.
#
# @param custom_blacklist
# Additional kernel modules to be blacklisted
#
Expand Down Expand Up @@ -50,6 +55,7 @@
'usb-storage'
],
Array[String] $custom_blacklist = [],
Boolean $produce_error = false,
Boolean $allow_overrides = true,
Boolean $lock_modules = false,
Boolean $notify_if_reboot_required = true
Expand Down Expand Up @@ -80,7 +86,12 @@
$_obsolete_disable_file = '/etc/modprobe.d/zz_simp_disable.conf'
}

$_disable_file_content = join($_blacklist.map |$mod| { "install ${mod} /bin/true" }, "\n")
$_produce_error = $produce_error ? {
true => '/bin/false',
false => '/bin/true',
}

$_disable_file_content = join($_blacklist.map |$mod| { "install ${mod} ${_produce_error}" }, "\n")

file { $_disable_file:
ensure => file,
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simp-simp",
"version": "4.21.0",
"version": "4.22.0",
"author": "SIMP Team",
"summary": "default profiles for core SIMP installations",
"license": "Apache-2.0",
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/00_classes/kmod_blacklist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@

end

context 'when producing an error on module load' do
let(:params){{
:produce_error => true
}}

it 'should blacklist all the default kmods and point to /bin/false' do
is_expected.to create_file("/etc/modprobe.d/zz_simp_disable.conf").with_content(stock_blacklist.map{|x| x = "install #{x} /bin/false" }.join("\n") + "\n")
end
end

end
end
end
Expand Down
Loading