diff options
author | Lance Albertson <lance@osuosl.org> | 2019-09-13 17:31:27 -0700 |
---|---|---|
committer | Lance Albertson <lance@osuosl.org> | 2019-09-13 22:39:58 -0700 |
commit | 37b763b64ae13e27d1b1de847e041441942fd498 (patch) | |
tree | c7882fec3c7f66bdd52ff6cde58fc6826c9197d4 | |
parent | 5048626424be5940caaff34b9aeee85918a2ec80 (diff) | |
download | chef-37b763b64ae13e27d1b1de847e041441942fd498.tar.gz |
Add options parameter for kernel_module
This adds a new parameter called ``options`` which allows users to set module
specific parameters and settings. This option file needs to be run before
loading the module so that the settings get loaded properly.
Signed-off-by: Lance Albertson <lance@osuosl.org>
-rw-r--r-- | lib/chef/resource/kernel_module.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/resource/kernel_module.rb b/lib/chef/resource/kernel_module.rb index 1176990071..85f5d3ca54 100644 --- a/lib/chef/resource/kernel_module.rb +++ b/lib/chef/resource/kernel_module.rb @@ -20,6 +20,9 @@ class Chef 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." + property :load_dir, String, description: "The directory to load modules from.", default: "/etc/modules-load.d" @@ -31,6 +34,12 @@ class Chef action :install do description "Load kernel module, and ensure it loads on reboot." + # create options file before loading the module + file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do + content "options #{new_resource.modname} #{new_resource.options.join(" ")}\n" + not_if { new_resource.options.nil? } + end.run_action(:create) + # load the module first before installing new_resource.run_action(:load) @@ -64,6 +73,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 |