diff options
author | Tim Smith <tsmith@chef.io> | 2019-09-16 11:54:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-16 11:54:34 -0700 |
commit | 6dee53f8fb7e72bb4d18c0b3db6e13919ab7605b (patch) | |
tree | 43d90038e291f98d090b724db3ec7e2f8228023d | |
parent | be061344736b1f18bbdf52cae2e06c08407149d7 (diff) | |
parent | 0008950ddf2ecbe1bd9e93248c3e8268157ecad2 (diff) | |
download | chef-6dee53f8fb7e72bb4d18c0b3db6e13919ab7605b.tar.gz |
Merge pull request #8887 from ramereth/kernel_module-modprobe-file
kernel_module: Add new options property
-rw-r--r-- | lib/chef/resource/kernel_module.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/chef/resource/kernel_module.rb b/lib/chef/resource/kernel_module.rb index 1176990071..2f9b7748f6 100644 --- a/lib/chef/resource/kernel_module.rb +++ b/lib/chef/resource/kernel_module.rb @@ -15,11 +15,61 @@ class Chef description "Use the kernel_module resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, install, and uninstall modules." introduced "14.3" + examples <<~DOC + Install and load a kernel module, and ensure it loads on reboot. + ```ruby + kernel_module 'loop' + ``` + Install and load a kernel with a specific set of options, and ensure it loads on reboot. Consult kernel module + documentation for specific options that are supported. + ```ruby + kernel_module 'loop' do + options [ + 'max_loop=4', + 'max_part=8' + ] + end + ``` + Load a kernel module. + ```ruby + kernel_module 'loop' do + action :load + end + ``` + Unload a kernel module and remove module config, so it doesn’t load on reboot. + ```ruby + kernel_module 'loop' do + action :uninstall + end + ``` + Unload kernel module. + ```ruby + kernel_module 'loop' do + action :unload + end + ``` + Blacklist a module from loading. + ```ruby + kernel_module 'loop' do + action :blacklist + end + ``` + Disable a kernel module. + ```ruby + kernel_module 'loop' do + action :disable + end + ``` + DOC property :modname, String, description: "An optional property to set the kernel module name if it differs from the resource block's name.", name_property: true, identity: true + property :options, Array, + description: "An optional property to set options for the kernel module.", + introduced: "15.4" + property :load_dir, String, description: "The directory to load modules from.", default: "/etc/modules-load.d" @@ -31,6 +81,13 @@ class Chef action :install do description "Load kernel module, and ensure it loads on reboot." + # create options file before loading the module + unless new_resource.options.nil? + file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do + content "options #{new_resource.modname} #{new_resource.options.join(" ")}\n" + end.run_action(:create) + end + # load the module first before installing new_resource.run_action(:load) @@ -64,6 +121,10 @@ class Chef notifies :run, "execute[update initramfs]", :delayed end + file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do + action :delete + end + with_run_context :root do find_resource(:execute, "update initramfs") do command initramfs_command |