Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # cookbooks/chef_notifier/libraries/chef_notifier.rb
- #
- # This monkeypatches Chef::Runner to report the result of run_action calls via MCollective
- require 'mcollective'
- class MRPC
- include MCollective::RPC
- def report_action(resource, action)
- options = MCollective::Util.default_options
- mc = rpcclient("chef_reporter", {:options => options})
- reqid = mc.log_action(
- :msg => {
- :resource => "#{resource}",
- :action => "#{action}",
- :updated? => "#{resource.updated_by_last_action?}",
- },
- :process_results => false)
- Chef::Log.debug "Sent status to MCollective with reqid #{reqid}"
- mc.disconnect
- end
- end
- class Chef
- class Runner
- alias_method :run_action_original, :run_action
- def run_action(resource, action)
- Chef::Log.debug "Wrapping run_action on #{resource} with MRPC.report_action"
- run_action_original(resource, action)
- MRPC.new.report_action(resource, action)
- end
- end
- end
Add Comment
Please, Sign In to add comment