summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-10-07 18:29:47 -0500
committerJames Turnbull <james@lovedthanlost.net>2008-10-08 11:23:43 +1100
commit3281f2b73ff20d72dca2f6a5063eb1ce23eb4ab2 (patch)
tree8b83f6f959f65f5e4b8bf2c767b5c783c685c029 /bin
parent0b1e60f69a03e6525e1a9eefd748c59b4fc5261c (diff)
downloadpuppet-3281f2b73ff20d72dca2f6a5063eb1ce23eb4ab2.tar.gz
puppet-3281f2b73ff20d72dca2f6a5063eb1ce23eb4ab2.tar.xz
puppet-3281f2b73ff20d72dca2f6a5063eb1ce23eb4ab2.zip
Fixed #1633 - Added support for --detailed-exits to bin/puppet
which causes puppet to produce different exit codes depending on whether there were changes or failures in the transaction. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/puppet26
1 files changed, 23 insertions, 3 deletions
diff --git a/bin/puppet b/bin/puppet
index 942902586..f3d8c252f 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -8,7 +8,7 @@
# = Usage
#
# puppet [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
-# [-l|--logdest <file>] <file>
+# [--detailed-exitcodes] [-l|--logdest <file>] <file>
#
# = Description
#
@@ -31,6 +31,11 @@
# debug::
# Enable full debugging.
#
+# detailed-exitcodes::
+# Provide transaction information via exit codes. If this is enabled, an exit
+# code of '2' means there were changes, and an exit code of '4' means that there
+# were failures during the transaction.
+#
# help::
# Print this help message
#
@@ -72,6 +77,7 @@ options = [
[ "--loadclasses", "-L", GetoptLong::NO_ARGUMENT ],
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
[ "--use-nodes", GetoptLong::NO_ARGUMENT ],
+ [ "--detailed-exitcodes", GetoptLong::NO_ARGUMENT ],
[ "--version", "-V", GetoptLong::NO_ARGUMENT ]
]
@@ -87,7 +93,8 @@ options = {
:logfile => false,
:loadclasses => false,
:logset => false,
- :code => nil
+ :code => nil,
+ :detailed_exits => false,
}
@@ -118,6 +125,8 @@ begin
options[:code] = arg
when "--loadclasses"
options[:loadclasses] = true
+ when "--detailed-exitcodes"
+ options[:detailed_exits] = true
when "--logdest"
begin
Puppet::Util::Log.newdestination(arg)
@@ -208,6 +217,7 @@ end
begin
# Compile our catalog
+ starttime = Time.now
catalog = Puppet::Node::Catalog.find(node.name, :use_node => node)
# Translate it to a RAL catalog
@@ -217,8 +227,18 @@ begin
catalog.finalize
+ catalog.retrieval_duration = Time.now - starttime
+
# And apply it
- catalog.apply
+ transaction = catalog.apply
+
+ status = 0
+ if not Puppet[:noop] and options[:detailed_exits] then
+ transaction.generate_report
+ status |= 2 if transaction.report.metrics["changes"][:total] > 0
+ status |= 4 if transaction.report.metrics["resources"][:failed] > 0
+ end
+ exit(status)
rescue => detail
if Puppet[:trace]
puts detail.backtrace