summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-05 10:00:51 -0800
committerGitHub <noreply@github.com>2018-11-05 10:00:51 -0800
commit8c5082e0f18781472532b61c17bc95b7cfd48a70 (patch)
tree3737e54b70bbc0e7037756c6ab1c7f41bbe524f7
parent8600950a8a39192788913f0c58ef3179656d1fe8 (diff)
parent7ebca90c4fd10e3c38b040ae2b84f4e1a5c9b400 (diff)
downloadchef-8c5082e0f18781472532b61c17bc95b7cfd48a70.tar.gz
Merge pull request #7871 from tomdoherty/run-initramfs_command-only-once
Defer running initramfs_command until end of run
-rw-r--r--lib/chef/resource/kernel_module.rb32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/chef/resource/kernel_module.rb b/lib/chef/resource/kernel_module.rb
index 0976b9c211..041ada9fed 100644
--- a/lib/chef/resource/kernel_module.rb
+++ b/lib/chef/resource/kernel_module.rb
@@ -40,12 +40,14 @@ class Chef
file "#{new_resource.load_dir}/#{new_resource.modname}.conf" do
content "#{new_resource.modname}\n"
- notifies :run, "execute[update initramfs]"
+ notifies :run, "execute[update initramfs]", :delayed
end
- execute "update initramfs" do
- command initramfs_command
- action :nothing
+ with_run_context :root do
+ find_resource(:execute, "update initramfs") do
+ command initramfs_command
+ action :nothing
+ end
end
end
@@ -54,17 +56,19 @@ class Chef
file "#{new_resource.load_dir}/#{new_resource.modname}.conf" do
action :delete
- notifies :run, "execute[update initramfs]"
+ notifies :run, "execute[update initramfs]", :delayed
end
file "#{new_resource.unload_dir}/blacklist_#{new_resource.modname}.conf" do
action :delete
- notifies :run, "execute[update initramfs]"
+ notifies :run, "execute[update initramfs]", :delayed
end
- execute "update initramfs" do
- command initramfs_command
- action :nothing
+ with_run_context :root do
+ find_resource(:execute, "update initramfs") do
+ command initramfs_command
+ action :nothing
+ end
end
new_resource.run_action(:unload)
@@ -75,12 +79,14 @@ class Chef
file "#{new_resource.unload_dir}/blacklist_#{new_resource.modname}.conf" do
content "blacklist #{new_resource.modname}"
- notifies :run, "execute[update initramfs]"
+ notifies :run, "execute[update initramfs]", :delayed
end
- execute "update initramfs" do
- command initramfs_command
- action :nothing
+ with_run_context :root do
+ find_resource(:execute, "update initramfs") do
+ command initramfs_command
+ action :nothing
+ end
end
new_resource.run_action(:unload)