From a76749a837a2552b72be34d91330f8983f740860 Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 14 Mar 2013 02:05:58 -0700 Subject: added exit codes for puppet apply --- vendor/supply_drop/lib/supply_drop/plugin.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'vendor/supply_drop') diff --git a/vendor/supply_drop/lib/supply_drop/plugin.rb b/vendor/supply_drop/lib/supply_drop/plugin.rb index 9649c5b..48198b4 100644 --- a/vendor/supply_drop/lib/supply_drop/plugin.rb +++ b/vendor/supply_drop/lib/supply_drop/plugin.rb @@ -71,15 +71,30 @@ fi writer = SupplyDrop::Writer::File.new(writer, puppet_write_to_file) unless puppet_write_to_file.nil? begin - run "#{puppet_cmd} #{flag}" do |channel, stream, data| - writer.collect_output(channel[:host], data) + exitcode = nil + run "#{puppet_cmd} #{flag}; echo exitcode:$?" do |channel, stream, data| + if data =~ /exitcode:(\d+)/ + exitcode = $1 + writer.collect_output(channel[:host], "Puppet #{command} complete (#{exitcode_description(exitcode)}).\n") + else + writer.collect_output(channel[:host], data) + end end - logger.debug "Puppet #{command} complete." ensure writer.all_output_collected end end + def exitcode_description(code) + case code + when "0" then "no changes" + when "2" then "changes made" + when "4" then "failed" + when "6" then "changes and failures" + else code + end + end + def red_text(text) "\033[0;31m#{text}\033[0m" end -- cgit v1.2.3