diff options
author | Tim Smith <tsmith@chef.io> | 2021-10-21 17:28:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 17:28:09 -0700 |
commit | 2fafbc8d5ac411880878d7b64eda4054efea2867 (patch) | |
tree | ae35bb8a174d9522b229489a2748ea5a69aa728e /lib | |
parent | 7ee28b18d1c2c40c2fb13a9c14a45c63c95a8b0e (diff) | |
parent | 3f5def1f1425e4905fbc832dab125f857b1ecd7f (diff) | |
download | chef-2fafbc8d5ac411880878d7b64eda4054efea2867.tar.gz |
Merge pull request #12105 from qubitrenegade/qbrd/kernel_module-enable
Add 'enable' action to 'kernel_module' resource to reverse 'disable' action.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/kernel_module.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/chef/resource/kernel_module.rb b/lib/chef/resource/kernel_module.rb index c4a36af9eb..4084dcbd70 100644 --- a/lib/chef/resource/kernel_module.rb +++ b/lib/chef/resource/kernel_module.rb @@ -15,7 +15,7 @@ class Chef provides :kernel_module - description "Use the **kernel_module** resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, install, and uninstall modules." + description "Use the **kernel_module** resource to manage kernel modules on Linux systems. This resource can load, unload, blacklist, disable, enable, install, and uninstall modules." introduced "14.3" examples <<~DOC Install and load a kernel module, and ensure it loads on reboot. @@ -68,13 +68,21 @@ class Chef end ``` - Disable a kernel module. + Disable a kernel module so that it is not installable. ```ruby kernel_module 'loop' do action :disable end ``` + + Enable a kernel module so that it is can be installed. Does not load or install. + + ```ruby + kernel_module 'loop' do + action :enable + end + ``` DOC property :modname, String, @@ -101,6 +109,9 @@ class Chef end end + # Remove the "disable file" before trying to install + action_enable + # create options file before loading the module unless new_resource.options.nil? file "#{new_resource.unload_dir}/options_#{new_resource.modname}.conf" do @@ -178,6 +189,20 @@ class Chef action_unload end + action :enable, description: "Enable a kernel module. Reverse :disable actions" do + with_run_context :root do + find_resource(:execute, "update initramfs") do + command initramfs_command + action :nothing + end + end + + file "#{new_resource.unload_dir}/disable_#{new_resource.modname}.conf" do + action :delete + notifies :run, "execute[update initramfs]", :delayed + end + end + action :load, description: "Load a kernel module." do unless module_loaded? converge_by("load kernel module #{new_resource.modname}") do |