diff options
author | Lance Albertson <lance@osuosl.org> | 2019-09-13 17:31:27 -0700 |
---|---|---|
committer | Lance Albertson <lance@osuosl.org> | 2019-11-21 10:53:46 -0800 |
commit | 78e7cc9fba2c6ba87650c488f09b6612f286f38d (patch) | |
tree | 3961ae2084cc6699a11ee6feb0985432f0c36640 | |
parent | 39fc6f9dd7a7531613e3bbc705dade0715ebfe79 (diff) | |
download | chef-78e7cc9fba2c6ba87650c488f09b6612f286f38d.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 0f2053334e..e5cef746c4 100644 --- a/lib/chef/resource/kernel_module.rb +++ b/lib/chef/resource/kernel_module.rb @@ -21,6 +21,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" @@ -32,6 +35,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) @@ -65,6 +74,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 |