diff options
author | elijah <elijah@riseup.net> | 2013-03-14 02:05:58 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-03-14 02:05:58 -0700 |
commit | a76749a837a2552b72be34d91330f8983f740860 (patch) | |
tree | ae392ced56be7dc35b22cbe37713b32deabdf169 /vendor/supply_drop/lib | |
parent | 2fd87063c0f48b67cb53bba6d52d82a091be6a7b (diff) |
added exit codes for puppet apply
Diffstat (limited to 'vendor/supply_drop/lib')
-rw-r--r-- | vendor/supply_drop/lib/supply_drop/plugin.rb | 21 |
1 files changed, 18 insertions, 3 deletions
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 |