From 37b763b64ae13e27d1b1de847e041441942fd498 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 13 Sep 2019 17:31:27 -0700 Subject: 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 --- lib/chef/resource/kernel_module.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 -- cgit v1.2.1