summaryrefslogtreecommitdiff
path: root/lib/chef/runner.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-10-15 12:56:41 -0700
committerJohn Keiser <john@johnkeiser.com>2015-12-09 10:26:08 -0800
commit90cddbbfcf5d7524485c41b6f1fccfe6756a7da4 (patch)
treed9bd4eaed6c329ab591c7698b7c56a5cf915bebf /lib/chef/runner.rb
parent2d915fee09e402bdba8928d28fdc12fa6c37f4c9 (diff)
downloadchef-90cddbbfcf5d7524485c41b6f1fccfe6756a7da4.tar.gz
Add immediately_before notification
Diffstat (limited to 'lib/chef/runner.rb')
-rw-r--r--lib/chef/runner.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
index 6125fe59e1..50554dcdbc 100644
--- a/lib/chef/runner.rb
+++ b/lib/chef/runner.rb
@@ -46,6 +46,29 @@ class Chef
# Determine the appropriate provider for the given resource, then
# execute it.
def run_action(resource, action, notification_type=nil, notifying_resource=nil)
+
+ # If there are any immediately_before notifications, why-run the resource
+ # and notify anyone who needs notifying
+ if !run_context.immediately_before_notifications(resource).empty?
+ whyrun_before = Chef::Config[:why_run]
+ begin
+ Chef::Config[:why_run] = true
+ Chef::Log.info("#{resource} running why-run #{action} action to support immediately_before action")
+ resource.run_action(action, notification_type, notifying_resource)
+ ensure
+ Chef::Config[:why_run] = whyrun_before
+ end
+
+ if resource.updated_by_last_action?
+ run_context.immediately_before_notifications(resource).each do |notification|
+ Chef::Log.info("#{resource} sending #{notification.action} action to #{notification.resource} (immediately_before)")
+ run_action(notification.resource, notification.action, :immediately_before, resource)
+ end
+ end
+
+ end
+
+ # Actually run the action for realsies
resource.run_action(action, notification_type, notifying_resource)
# Execute any immediate and queue up any delayed notifications