summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-10-17 09:01:04 -0500
committerLuke Kanies <luke@madstop.com>2008-10-17 09:01:04 -0500
commit8aee40de69e6fe8d67ab58a2e223443b15820584 (patch)
tree89e230df3b43302a542f2cb6869f63e2fb93f6d8 /bin
parent1b517d2fb048603bd1743a662bde74e8ae4b13dc (diff)
parenta74ec60d33dee1c592ec858faeccc23d7a7b79f3 (diff)
downloadpuppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.gz
puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.tar.xz
puppet-8aee40de69e6fe8d67ab58a2e223443b15820584.zip
Merge branch '0.24.x' Removed the 'after' blocks that call Type.clear,
since that method is deprecated. Conflicts: CHANGELOG bin/puppetca lib/puppet/file_serving/fileset.rb lib/puppet/network/xmlrpc/client.rb lib/puppet/type/file/selcontext.rb spec/unit/file_serving/metadata.rb spec/unit/type/file.rb
Diffstat (limited to 'bin')
-rwxr-xr-xbin/puppet43
1 files changed, 32 insertions, 11 deletions
diff --git a/bin/puppet b/bin/puppet
index 0e64b1cf3..f3d8c252f 100755
--- a/bin/puppet
+++ b/bin/puppet
@@ -3,18 +3,18 @@
#
# = Synopsis
#
-# Run a stand-alone +puppet+ script.
+# Run a stand-alone +puppet+ manifest.
#
# = Usage
#
# puppet [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
-# [-l|--logdest <file>] <file>
+# [--detailed-exitcodes] [-l|--logdest <file>] <file>
#
# = Description
#
-# This is the standalone puppet execution script; use it to execute
-# individual scripts that you write. If you need to execute site-wide
-# scripts, use +puppetd+ and +puppetmasterd+.
+# This is the standalone puppet execution tool; use it to execute
+# individual manifests that you write. If you need to execute site-wide
+# manifests, use +puppetd+ and +puppetmasterd+.
#
# = Options
#
@@ -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
#
@@ -48,7 +53,7 @@
#
# = Example
#
-# puppet -l /tmp/script.log script.pp
+# puppet -l /tmp/manifest.log manifest.pp
#
# = Author
#
@@ -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)
@@ -183,11 +192,12 @@ if Puppet[:parseonly]
end
# Collect our facts.
-facts = Puppet::Node::Facts.find("me")
-facts.name = facts.values["hostname"]
+facts = Puppet::Node::Facts.find(Puppet[:certname])
# Find our Node
-node = Puppet::Node.find(facts.name)
+unless node = Puppet::Node.find(Puppet[:certname])
+ raise "Could not find node %s" % Puppet[:certname]
+end
# Merge in the facts.
node.merge(facts.values)
@@ -207,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
@@ -216,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