[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Jesse Wolfe
jes5199 at gmail.com
Tue May 10 08:04:26 UTC 2011
The following commit has been merged in the experimental branch:
commit dd68914eb25d8dd9aac5c8ced39fa0d05136ed9f
Merge: ea348761df0b5297dbac50c7f1c48d22746524fa 3f2f1c2456cf5f08bd67ab5730ab970be5285711
Author: Jesse Wolfe <jes5199 at gmail.com>
Date: Thu Feb 3 16:47:51 2011 -0800
Merge branch 'maint/2.6.next/help' into next
diff --combined lib/puppet/application/agent.rb
index 96f3329,5dc4255..fa1ec58
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@@ -83,6 -83,212 +83,212 @@@ class Puppet::Application::Agent < Pupp
@args[:Port] = arg
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ Retrieve the client configuration from the puppet master and apply it to
+ the local host.
+
+ Currently must be run out periodically, using cron or something similar.
+
+
+ USAGE
+ =====
+ puppet agent [-D|--daemonize|--no-daemonize] [-d|--debug]
+ [--detailed-exitcodes] [--disable] [--enable]
+ [-h|--help] [--certname <host name>] [-l|--logdest syslog|<file>|console]
+ [-o|--onetime] [--serve <handler>] [-t|--test] [--noop]
+ [--digest <digest>] [--fingerprint] [-V|--version]
+ [-v|--verbose] [-w|--waitforcert <seconds>]
+
+
+ DESCRIPTION
+ ===========
+ This is the main puppet client. Its job is to retrieve the local
+ machine's configuration from a remote server and apply it. In order to
+ successfully communicate with the remote server, the client must have a
+ certificate signed by a certificate authority that the server trusts;
+ the recommended method for this, at the moment, is to run a certificate
+ authority as part of the puppet server (which is the default). The
+ client will connect and request a signed certificate, and will continue
+ connecting until it receives one.
+
+ Once the client has a signed certificate, it will retrieve its
+ configuration and apply it.
+
+
+ USAGE NOTES
+ ===========
+ 'puppet agent' does its best to find a compromise between interactive
+ use and daemon use. Run with no arguments and no configuration, it will
+ go into the backgroun, attempt to get a signed certificate, and retrieve
+ and apply its configuration every 30 minutes.
+
+ Some flags are meant specifically for interactive use -- in particular,
+ 'test', 'tags' or 'fingerprint' are useful. 'test' enables verbose
+ logging, causes the daemon to stay in the foreground, exits if the
+ server's configuration is invalid (this happens if, for instance, you've
+ left a syntax error on the server), and exits after running the
+ configuration once (rather than hanging around as a long-running
+ process).
+
+ 'tags' allows you to specify what portions of a configuration you want
+ to apply. Puppet elements are tagged with all of the class or definition
+ names that contain them, and you can use the 'tags' flag to specify one
+ of these names, causing only configuration elements contained within
+ that class or definition to be applied. This is very useful when you are
+ testing new configurations -- for instance, if you are just starting to
+ manage 'ntpd', you would put all of the new elements into an 'ntpd'
+ class, and call puppet with '--tags ntpd', which would only apply that
+ small portion of the configuration during your testing, rather than
+ applying the whole thing.
+
+ 'fingerprint' is a one-time flag. In this mode 'puppet agent' will run
+ once and display on the console (and in the log) the current certificate
+ (or certificate request) fingerprint. Providing the '--digest' option
+ allows to use a different digest algorithm to generate the fingerprint.
+ The main use is to verify that before signing a certificate request on
+ the master, the certificate request the master received is the same as
+ the one the client sent (to prevent against man-in-the-middle attacks
+ when signing certificates).
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'server' is a valid
+ configuration parameter, so you can specify '--server <servername>' as
+ an argument.
+
+ See the configuration file documentation at
+ http://docs.puppetlabs.com/references/stable/configuration.html for the
+ full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppet agent with
+ '--genconfig'.
+
+ daemonize: Send the process into the background. This is the
+ default.
+
+ no-daemonize: Do not send the process into the background.
+
+ debug: Enable full debugging.
+
+ digest: Change the certificate fingerprinting digest
+ algorithm. The default is MD5. Valid values depends
+ on the version of OpenSSL installed, but should
+ always at least contain MD5, MD2, SHA1 and SHA256.
+
+ 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. This
+ option only makes sense in conjunction with
+ --onetime.
+
+ disable: Disable working on the local system. This puts a
+ lock file in place, causing 'puppet agent' not to
+ work on the system until the lock file is removed.
+ This is useful if you are testing a configuration
+ and do not want the central configuration to
+ override the local state until everything is tested
+ and committed.
+
+ 'puppet agent' uses the same lock file while it is running, so no more
+ than one 'puppet agent' process is working at a time.
+
+ 'puppet agent' exits after executing this.
+
+ enable: Enable working on the local system. This removes any
+ lock file, causing 'puppet agent' to start managing
+ the local system again (although it will continue to
+ use its normal scheduling, so it might not start for
+ another half hour).
+
+ 'puppet agent' exits after executing this.
+
+ certname: Set the certname (unique ID) of the client. The
+ master reads this unique identifying string, which
+ is usually set to the node's fully-qualified domain
+ name, to determine which configurations the node
+ will receive. Use this option to debug setup
+ problems or implement unusual node identification
+ schemes.
+
+ help: Print this help message
+
+ logdest: Where to send messages. Choose between syslog, the
+ console, and a log file. Defaults to sending
+ messages to syslog, or the console if debugging or
+ verbosity is enabled.
+
+ no-client: Do not create a config client. This will cause the
+ daemon to run without ever checking for its
+ configuration automatically, and only makes sense
+
+ onetime: Run the configuration once. Runs a single (normally
+ daemonized) Puppet run. Useful for interactively
+ running puppet agent when used in conjunction with
+ the --no-daemonize option.
+
+ fingerprint: Display the current certificate or certificate
+ signing request fingerprint and then exit. Use the
+ '--digest' option to change the digest algorithm
+ used.
+
+ serve: Start another type of server. By default, 'puppet
+ agent' will start a service handler that allows
+ authenticated and authorized remote nodes to trigger
+ the configuration to be pulled down and applied. You
+ can specify any handler here that does not require
+ configuration, e.g., filebucket, ca, or resource.
+ The handlers are in 'lib/puppet/network/handler',
+ and the names must match exactly, both in the call
+ to 'serve' and in 'namespaceauth.conf'.
+
+ test: Enable the most common options used for testing.
+ These are 'onetime', 'verbose', 'ignorecache',
+ 'no-daemonize', 'no-usecacheonfailure',
+ 'detailed-exit-codes', 'no-splay', and 'show_diff'.
+
+ noop: Use 'noop' mode where the daemon runs in a no-op or
+ dry-run mode. This is useful for seeing what changes
+ Puppet will make without actually executing the
+ changes.
+
+ verbose: Turn on verbose reporting.
+
+ version: Print the puppet version number and exit.
+
+ waitforcert: This option only matters for daemons that do not yet
+ have certificates and it is enabled by default, with
+ a value of 120 (seconds). This causes 'puppet agent'
+ to connect to the server every 2 minutes and ask it
+ to sign a certificate request. This is useful for
+ the initial setup of a puppet client. You can turn
+ off waiting for certificates by specifying a time of
+ 0.
+
+
+ EXAMPLE
+ =======
+ puppet agent --server puppet.domain.com
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2005, 2006 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def run_command
return fingerprint if options[:fingerprint]
return onetime if Puppet[:onetime]
@@@ -228,9 -434,7 +434,9 @@@
# access to the local files and we don't need a ca.
Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote
- Puppet::Transaction::Report.terminus_class = :rest
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
+ # we want the last report to be persisted locally
+ Puppet::Transaction::Report.indirection.cache_class = :yaml
# Override the default; puppetd needs this, usually.
# You can still override this on the command-line with, e.g., :compiler.
@@@ -239,7 -443,8 +445,7 @@@
# Override the default.
Puppet[:facts_terminus] = :facter
- Puppet::Resource::Catalog.cache_class = :yaml
-
+ Puppet::Resource::Catalog.indirection.cache_class = :yaml
# We need tomake the client either way, we just don't start it
# if --no-client is set.
diff --combined lib/puppet/application/apply.rb
index e5b4bb5,63a51f2..1a5ab2c
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@@ -26,6 -26,82 +26,82 @@@ class Puppet::Application::Apply < Pupp
end
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ Run a stand-alone 'puppet' manifest.
+
+
+ USAGE
+ =====
+ puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose] [-e|--execute]
+ [--detailed-exitcodes] [-l|--logdest <file>] <file>
+
+
+ DESCRIPTION
+ ===========
+ 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 'puppet agent' and 'puppet master'.
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'ssldir' is a valid
+ configuration parameter, so you can specify '--ssldir <directory>' as an
+ argument.
+
+ See the configuration file documentation at
+ http://docs.puppetlabs.com/references/stable/configuration.html for the
+ full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppet with
+ '--genconfig'.
+
+ 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
+
+ loadclasses: Load any stored classes. 'puppet agent' caches
+ configured classes (usually at
+ /etc/puppet/classes.txt), and setting this option
+ causes all of those classes to be set in your puppet
+ manifest.
+
+ logdest: Where to send messages. Choose between syslog, the
+ console, and a log file. Defaults to sending
+ messages to the console.
+
+ execute: Execute a specific piece of Puppet code
+
+ verbose: Print extra information.
+
+
+ EXAMPLE
+ =======
+ puppet -l /tmp/manifest.log manifest.pp
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def run_command
if options[:catalog]
apply
@@@ -85,12 -161,12 +161,12 @@@
end
# Collect our facts.
- unless facts = Puppet::Node::Facts.find(Puppet[:certname])
+ unless facts = Puppet::Node::Facts.indirection.find(Puppet[:certname])
raise "Could not find facts for #{Puppet[:certname]}"
end
# Find our Node
- unless node = Puppet::Node.find(Puppet[:certname])
+ unless node = Puppet::Node.indirection.find(Puppet[:certname])
raise "Could not find node #{Puppet[:certname]}"
end
@@@ -112,7 -188,7 +188,7 @@@
begin
# Compile our catalog
starttime = Time.now
- catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node)
+ catalog = Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
# Translate it to a RAL catalog
catalog = catalog.to_ral
@@@ -148,9 -224,6 +224,9 @@@
exit(1)
end
+ # we want the last report to be persisted locally
+ Puppet::Transaction::Report.indirection.cache_class = :yaml
+
if options[:debug]
Puppet::Util::Log.level = :debug
elsif options[:verbose]
diff --combined lib/puppet/application/inspect.rb
index 19324e2,cee66de..599898a
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@@ -19,6 -19,59 +19,59 @@@ class Puppet::Application::Inspect < Pu
end
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+
+ Prepare and submit an inspection report to the puppet master.
+
+
+ USAGE
+ =====
+
+ puppet inspect
+
+
+ DESCRIPTION
+ ===========
+
+ This command uses the cached catalog from the previous run of 'puppet
+ agent' to determine which attributes of which resources have been
+ marked as auditable with the 'audit' metaparameter. It then examines
+ the current state of the system, writes the state of the specified
+ resource attributes to a report, and submits the report to the puppet
+ master.
+
+ Puppet inspect does not run as a daemon, and must be run manually or from cron.
+
+
+ OPTIONS
+ =======
+
+ Any configuration setting which is valid in the configuration file is
+ also a valid long argument, e.g. '--server=master.domain.com'. See the
+ configuration file documentation at
+ http://docs.puppetlabs.com/references/latest/configuration.html for
+ the full list of acceptable settings.
+
+
+ AUTHOR
+ ======
+
+ Puppet Labs
+
+
+ COPYRIGHT
+ =========
+
+ Copyright (c) 2011 Puppet Labs, LLC
+ Licensed under the GNU General Public License version 2
+
+ HELP
+ end
+
def setup
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
@@@ -40,14 -93,14 +93,14 @@@
Puppet::Util::Log.level = :info
end
- Puppet::Transaction::Report.terminus_class = :rest
- Puppet::Resource::Catalog.terminus_class = :yaml
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Resource::Catalog.indirection.terminus_class = :yaml
end
def run_command
retrieval_starttime = Time.now
- unless catalog = Puppet::Resource::Catalog.find(Puppet[:certname])
+ unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname])
raise "Could not find catalog for #{Puppet[:certname]}"
end
@@@ -114,7 -167,7 +167,7 @@@
@report.finalize_report
begin
- @report.save
+ Puppet::Transaction::Report.indirection.save(@report)
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not send report: #{detail}"
diff --combined lib/puppet/application/kick.rb
index 12dad65,c05f097..4cf0603
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@@ -37,6 -37,137 +37,137 @@@ class Puppet::Application::Kick < Puppe
end
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ Trigger a puppet agent run on a set of hosts.
+
+
+ USAGE
+ =====
+ puppet kick [-a|--all] [-c|--class <class>] [-d|--debug] [-f|--foreground]
+ [-h|--help] [--host <host>] [--no-fqdn] [--ignoreschedules]
+ [-t|--tag <tag>] [--test] [-p|--ping] <host> [<host> [...]]
+
+
+ DESCRIPTION
+ ===========
+ This script can be used to connect to a set of machines running 'puppet
+ agent' and trigger them to run their configurations. The most common
+ usage would be to specify a class of hosts and a set of tags, and
+ 'puppet kick' would look up in LDAP all of the hosts matching that
+ class, then connect to each host and trigger a run of all of the objects
+ with the specified tags.
+
+ If you are not storing your host configurations in LDAP, you can specify
+ hosts manually.
+
+ You will most likely have to run 'puppet kick' as root to get access to
+ the SSL certificates.
+
+ 'puppet kick' reads 'puppet master''s configuration file, so that it can
+ copy things like LDAP settings.
+
+
+ USAGE NOTES
+ ===========
+ 'puppet kick' is useless unless 'puppet agent' is listening. See its
+ documentation for more information, but the gist is that you must enable
+ 'listen' on the 'puppet agent' daemon, either using '--listen' on the
+ command line or adding 'listen: true' in its config file. In addition,
+ you need to set the daemons up to specifically allow connections by
+ creating the 'namespaceauth' file, normally at
+ '/etc/puppet/namespaceauth.conf'. This file specifies who has access to
+ each namespace; if you create the file you must add every namespace you
+ want any Puppet daemon to allow -- it is currently global to all Puppet
+ daemons.
+
+ An example file looks like this::
+
+ [fileserver]
+ allow *.madstop.com
+
+ [puppetmaster]
+ allow *.madstop.com
+
+ [puppetrunner]
+ allow culain.madstop.com
+
+ This is what you would install on your Puppet master; non-master hosts
+ could leave off the 'fileserver' and 'puppetmaster' namespaces.
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'ssldir' is a valid
+ configuration parameter, so you can specify '--ssldir <directory>' as an
+ argument.
+
+ See the configuration file documentation at
+ http://reductivelabs.com/projects/puppet/reference/configref.html for
+ the full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppet master
+ with '--genconfig'.
+
+ all: Connect to all available hosts. Requires LDAP support
+ at this point.
+
+ class: Specify a class of machines to which to connect. This
+ only works if you have LDAP configured, at the moment.
+
+ debug: Enable full debugging.
+
+ foreground: Run each configuration in the foreground; that is, when
+ connecting to a host, do not return until the host has
+ finished its run. The default is false.
+
+ help: Print this help message
+
+ host: A specific host to which to connect. This flag can be
+ specified more than once.
+
+ ignoreschedules: Whether the client should ignore schedules when running
+ its configuration. This can be used to force the client
+ to perform work it would not normally perform so soon.
+ The default is false.
+
+ parallel: How parallel to make the connections. Parallelization
+ is provided by forking for each client to which to
+ connect. The default is 1, meaning serial execution.
+
+ tag: Specify a tag for selecting the objects to apply. Does
+ not work with the --test option.
+
+ test: Print the hosts you would connect to but do not
+ actually connect. This option requires LDAP support at
+ this point.
+
+ ping::
+
+ Do a ICMP echo against the target host. Skip hosts that don't respond to ping.
+
+
+ EXAMPLE
+ =======
+ sudo puppet kick -p 10 -t remotefile -t webserver host1 host2
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def run_command
@hosts += command_line.args
options[:test] ? test : main
@@@ -120,7 -251,7 +251,7 @@@
:background => ! options[:foreground],
:ignoreschedules => options[:ignoreschedules]
}
- run = Puppet::Run.new( run_options ).save( url )
+ run = Puppet::Run.indirection.save(Puppet::Run.new( run_options ), url)
puts "Getting status"
result = run.status
puts "status is #{result}"
@@@ -175,12 -306,12 +306,12 @@@
if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes)
if options[:all]
- @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
+ @hosts = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
puts "all: #{@hosts.join(", ")}"
else
@hosts = []
@classes.each do |klass|
- list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
+ list = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
puts "#{klass}: #{list.join(", ")}"
@hosts += list
diff --combined lib/puppet/application/master.rb
index 879b66c,398c069..b2b77f8
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@@ -25,6 -25,83 +25,83 @@@ class Puppet::Application::Master < Pup
end
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ The central puppet server. Functions as a certificate authority by
+ default.
+
+
+ USAGE
+ =====
+ puppet master [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help]
+ [-l|--logdest <file>|console|syslog] [-v|--verbose] [-V|--version]
+ [--compile <nodename>] [--apply <catalog>]
+
+ DESCRIPTION
+ ===========
+ This is the puppet central daemon.
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'ssldir' is a valid
+ configuration parameter, so you can specify '--ssldir <directory>' as an
+ argument.
+
+ See the configuration file documentation at
+ http://docs.puppetlabs.com/references/stable/configuration.html for the
+ full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppetmasterdd
+ with '--genconfig'.
+
+ daemonize: Send the process into the background. This is the default.
+
+ no-daemonize: Do not send the process into the background.
+
+ debug: Enable full debugging.
+
+ help: Print this help message.
+
+ logdest: Where to send messages. Choose between syslog, the
+ console, and a log file. Defaults to sending messages to
+ syslog, or the console if debugging or verbosity is
+ enabled.
+
+ verbose: Enable verbosity.
+
+ version: Print the puppet version number and exit.
+
+ compile: Capability to compile a catalogue and output it in JSON
+ from the Puppet master. Uses facts contained in the
+ $vardir/yaml/ directory to compile the catalog.
+
+ apply: Capability to apply JSON catalog (such as one generated
+ with --compile). You can either specify a JSON file or
+ pipe in JSON from standard input.
+
+
+ EXAMPLE
+ =======
+ puppet master
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2005 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def preinit
trap(:INT) do
$stderr.puts "Cancelling startup"
@@@ -51,7 -128,7 +128,7 @@@
Puppet::Util::Log.newdestination :console
raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson?
begin
- unless catalog = Puppet::Resource::Catalog.find(options[:node])
+ unless catalog = Puppet::Resource::Catalog.indirection.find(options[:node])
raise "Could not compile catalog for #{options[:node]}"
end
@@@ -139,7 -216,7 +216,7 @@@
Puppet.settings.use :main, :master, :ssl
# Cache our nodes in yaml. Currently not configurable.
- Puppet::Node.cache_class = :yaml
+ Puppet::Node.indirection.cache_class = :yaml
# Configure all of the SSL stuff.
if Puppet::SSL::CertificateAuthority.ca?
diff --combined lib/puppet/application/queue.rb
index b9e8ca4,6511771..d32ec9a
--- a/lib/puppet/application/queue.rb
+++ b/lib/puppet/application/queue.rb
@@@ -37,16 -37,75 +37,75 @@@ class Puppet::Application::Queue < Pupp
option("--debug","-d")
option("--verbose","-v")
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ Retrieve serialized records from a queue and process them in order.
+
+
+ USAGE
+ =====
+ puppet queue [-d|--debug] [-v|--verbose]
+
+
+ DESCRIPTION
+ ===========
+ This is a simple application that just processes entities in a queue as
+ they are recieved.
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'server' is a valid
+ configuration parameter, so you can specify '--server <servername>' as
+ an argument.
+
+ See the configuration file documentation at
+ http://docs.puppetlabs.com/references/stable/configuration.html for the
+ full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppetd with
+ '--genconfig'.
+
+ debug: Enable full debugging.
+
+ help: Print this help message
+
+ verbose: Turn on verbose reporting.
+
+ version: Print the puppet version number and exit.
+
+
+ EXAMPLE
+ =======
+ puppet queue
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2009 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def main
require 'puppet/indirector/catalog/queue' # provides Puppet::Indirector::Queue.subscribe
Puppet.notice "Starting puppetqd #{Puppet.version}"
Puppet::Resource::Catalog::Queue.subscribe do |catalog|
- # Once you have a Puppet::Resource::Catalog instance, calling save on it should suffice
+ # Once you have a Puppet::Resource::Catalog instance, passing it to save should suffice
# to put it through to the database via its active_record indirector (which is determined
# by the terminus_class = :active_record setting above)
Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do
begin
- catalog.save
+ Puppet::Resource::Catalog.indirection.save(catalog)
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}"
@@@ -79,7 -138,7 +138,7 @@@
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
require 'puppet/resource/catalog'
- Puppet::Resource::Catalog.terminus_class = :active_record
+ Puppet::Resource::Catalog.indirection.terminus_class = :active_record
daemon.daemonize if Puppet[:daemonize]
@@@ -87,6 -146,6 +146,6 @@@
# class set up, because if storeconfigs is enabled,
# we'll get a loop of continually caching the catalog
# for storage again.
- Puppet::Resource::Catalog.cache_class = nil
+ Puppet::Resource::Catalog.indirection.cache_class = nil
end
end
diff --combined lib/puppet/application/resource.rb
index c7c1c28,55b190a..a0e3340
--- a/lib/puppet/application/resource.rb
+++ b/lib/puppet/application/resource.rb
@@@ -35,6 -35,110 +35,110 @@@ class Puppet::Application::Resource < P
@extra_params << arg.to_sym
end
+ def help
+ <<-HELP
+
+ SYNOPSIS
+ ========
+ Use the Puppet RAL to directly interact with the system.
+
+
+ USAGE
+ =====
+ puppet resource [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit]
+ [-H|--host <host>] [-p|--param <param>] [-t|--types]
+ type <name>
+
+
+ DESCRIPTION
+ ===========
+ This command provides simple facilities for converting current system
+ state into Puppet code, along with some ability to use Puppet to affect
+ the current state.
+
+ By default, you must at least provide a type to list, which case puppet
+ resource will tell you everything it knows about all instances of that
+ type. You can optionally specify an instance name, and puppet resource
+ will only describe that single instance.
+
+ You can also add '--edit' as an argument, and puppet resource will write
+ its output to a file, open that file in an editor, and then apply the
+ file as a Puppet transaction. You can easily use this to use Puppet to
+ make simple changes to a system.
+
+
+ OPTIONS
+ =======
+ Note that any configuration parameter that's valid in the configuration
+ file is also a valid long argument. For example, 'ssldir' is a valid
+ configuration parameter, so you can specify '--ssldir <directory>' as an
+ argument.
+
+ See the configuration file documentation at
+ http://docs.puppetlabs.com/references/stable/configuration.html for the
+ full list of acceptable parameters. A commented list of all
+ configuration options can also be generated by running puppet with
+ '--genconfig'.
+
+ debug: Enable full debugging.
+
+ edit:
+
+ Write the results of the query to a file, open the file in an editor,
+ and read the file back in as an executable Puppet manifest.
+
+ host:
+
+ When specified, connect to the resource server on the named host
+ and retrieve the list of resouces of the type specified.
+
+ help:
+
+ Print this help message.
+
+ param:
+
+ Add more parameters to be outputted from queries.
+
+ types:
+
+ List all available types.
+
+ verbose:
+
+ Print extra information.
+
+
+ EXAMPLE
+ =======
+ This example uses `puppet resource` to return Puppet configuration for
+ the user `luke`:
+
+ $ puppet resource user luke
+ user { 'luke':
+ home => '/home/luke',
+ uid => '100',
+ ensure => 'present',
+ comment => 'Luke Kanies,,,',
+ gid => '1000',
+ shell => '/bin/bash',
+ groups => ['sysadmin','audio','video','puppet']
+ }
+
+
+ AUTHOR
+ ======
+ Luke Kanies
+
+
+ COPYRIGHT
+ =========
+ Copyright (c) 2005-2007 Puppet Labs, LLC Licensed under the GNU Public
+ License
+
+ HELP
+ end
+
def main
args = command_line.args
type = args.shift or raise "You must specify the type to display"
@@@ -76,12 -180,12 +180,12 @@@
text = if name
if params.empty?
- [ Puppet::Resource.find( key ) ]
+ [ Puppet::Resource.indirection.find( key ) ]
else
- [ Puppet::Resource.new( type, name, :parameters => params ).save( key ) ]
+ [ Puppet::Resource.indirection.save(Puppet::Resource.new( type, name, :parameters => params ), key) ]
end
else
- Puppet::Resource.search( key, {} )
+ Puppet::Resource.indirection.search( key, {} )
end.map(&format).join("\n")
if options[:edit]
diff --combined lib/puppet/defaults.rb
index e3b86bc,687ac4e..576acfe
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@@ -14,7 -14,11 +14,11 @@@ module Puppe
setdefaults(:main,
:trace => [false, "Whether to print stack traces on some errors"],
- :autoflush => [false, "Whether log files should always flush to disk."],
+ :autoflush => {
+ :default => false,
+ :desc => "Whether log files should always flush to disk.",
+ :hook => proc { |value| Log.autoflush = value }
+ },
:syslogfacility => ["daemon", "What syslog facility to use when logging to
syslog. Syslog has a fixed list of valid facilities, and you must
choose one of those; you cannot just make one up."],
@@@ -115,17 -119,7 +119,17 @@@
:node_terminus => ["plain", "Where to find information about nodes."],
:catalog_terminus => ["compiler", "Where to get node catalogs. This is useful to change if, for instance,
you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store."],
- :facts_terminus => [Puppet.application_name.to_s == "master" ? 'yaml' : 'facter', "The node facts terminus."],
+ :facts_terminus => {
+ :default => Puppet.application_name.to_s == "master" ? 'yaml' : 'facter',
+ :desc => "The node facts terminus.",
+ :hook => proc do |value|
+ require 'puppet/node/facts'
+ if value.to_s == "rest"
+ Puppet::Node::Facts.indirection.cache_class = :yaml
+ end
+ end
+ },
+ :inventory_terminus => [ "$facts_terminus", "Should usually be the same as the facts terminus" ],
:httplog => { :default => "$logdir/http.log",
:owner => "root",
:mode => 0640,
@@@ -152,7 -146,7 +156,7 @@@
Puppet.settings[:storeconfigs] = true
# But then we modify the configuration
- Puppet::Resource::Catalog.cache_class = :queue
+ Puppet::Resource::Catalog.indirection.cache_class = :queue
else
raise "Cannot disable asynchronous storeconfigs in a running process"
end
@@@ -588,28 -582,14 +592,28 @@@
end
},
:report_server => ["$server",
- "The server to which to send transaction reports."
+ "The server to send transaction reports to."
],
:report_port => ["$masterport",
"The port to communicate with the report_server."
],
- :report => [false,
+ :inventory_server => ["$server",
+ "The server to send facts to."
+ ],
+ :inventory_port => ["$masterport",
+ "The port to communicate with the inventory_server."
+ ],
+ :report => [true,
"Whether to send reports after every transaction."
],
+ :lastrunfile => { :default => "$statedir/last_run_summary.yaml",
+ :mode => 0660,
+ :desc => "Where puppet agent stores the last run report summary in yaml format."
+ },
+ :lastrunreport => { :default => "$statedir/last_run_report.yaml",
+ :mode => 0660,
+ :desc => "Where puppet agent stores the last run report in yaml format."
+ },
:graph => [false, "Whether to create dot graph files for the different
configuration graphs. These dot files can be interpreted by tools
like OmniGraffle or dot (which is part of ImageMagick)."],
@@@ -799,9 -779,9 +803,9 @@@
if value
require 'puppet/rails'
raise "StoreConfigs not supported without ActiveRecord 2.1 or higher" unless Puppet.features.rails?
- Puppet::Resource::Catalog.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
- Puppet::Node::Facts.cache_class = :active_record
- Puppet::Node.cache_class = :active_record
+ Puppet::Resource::Catalog.indirection.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
+ Puppet::Node::Facts.indirection.cache_class = :active_record
+ Puppet::Node.indirection.cache_class = :active_record
end
end
}
diff --combined lib/puppet/util/log.rb
index 2f9f356,ba16900..d34fbaf
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@@ -58,7 -58,6 +58,7 @@@ class Puppet::Util::Lo
destinations.keys.each { |dest|
close(dest)
}
+ raise Puppet::DevError.new("Log.close_all failed to close #{@destinations.keys.inspect}") if !@destinations.empty?
end
# Flush any log destinations that support such operations.
@@@ -68,6 -67,12 +68,12 @@@
}
end
+ def Log.autoflush=(v)
+ @destinations.each do |type, dest|
+ dest.autoflush = v if dest.respond_to?(:autoflush=)
+ end
+ end
+
# Create a new log message. The primary role of this method is to
# avoid creating log messages below the loglevel.
def Log.create(hash)
diff --combined lib/puppet/util/log/destinations.rb
index 2e2f9a5,c70edeb..dd0d996
--- a/lib/puppet/util/log/destinations.rb
+++ b/lib/puppet/util/log/destinations.rb
@@@ -50,6 -50,8 +50,8 @@@ Puppet::Util::Log.newdesttype :file d
@file.flush if defined?(@file)
end
+ attr_accessor :autoflush
+
def initialize(path)
@name = path
# first make sure the directory exists
@@@ -203,20 -205,8 +205,20 @@@ Puppet::Util::Log.newdesttype :report d
end
# Log to an array, just for testing.
+module Puppet::Test
+ class LogCollector
+ def initialize(logs)
+ @logs = logs
+ end
+
+ def <<(value)
+ @logs << value
+ end
+ end
+end
+
Puppet::Util::Log.newdesttype :array do
- match "Array"
+ match "Puppet::Test::LogCollector"
def initialize(messages)
@messages = messages
diff --combined spec/unit/application_spec.rb
index 65f0616,1446535..ca663e3
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'puppet/application'
require 'puppet'
@@@ -46,6 -46,48 +46,48 @@@ describe Puppet::Application d
end
end
+ it "should sadly and frighteningly allow run_mode to change at runtime" do
+ class TestApp < Puppet::Application
+ run_mode :master
+ def run_command
+ # This is equivalent to calling these methods externally to the
+ # instance, but since this is what "real world" code is likely to do
+ # (and we need the class anyway) we may as well test that. --daniel 2011-02-03
+ set_run_mode self.class.run_mode "agent"
+ end
+ end
+
+ Puppet[:run_mode].should == "user"
+
+ expect {
+ app = TestApp.new
+
+ Puppet[:run_mode].should == "master"
+
+ app.run
+
+ app.class.run_mode.name.should == :agent
+ $puppet_application_mode.name.should == :agent
+ }.should_not raise_error
+
+ Puppet[:run_mode].should == "agent"
+ end
+
+ it "it should not allow run mode to be set multiple times" do
+ pending "great floods of tears, you can do this right now" # --daniel 2011-02-03
+ app = Puppet::Application.new
+ expect {
+ app.set_run_mode app.class.run_mode "master"
+ $puppet_application_mode.name.should == :master
+ app.set_run_mode app.class.run_mode "agent"
+ $puppet_application_mode.name.should == :agent
+ }.should raise_error
+ end
+
+ it "should explode when an invalid run mode is set at runtime, for great victory"
+ # ...but you can, and while it will explode, that only happens too late for
+ # us to easily test. --daniel 2011-02-03
+
it "should have a run entry-point" do
@app.should respond_to(:run)
end
@@@ -241,11 -283,10 +283,10 @@@
@app.parse_options
end
- describe "when using --help", :if => Puppet.features.usage? do
+ describe "when using --help" do
- it "should call RDoc::usage and exit" do
+ it "should call exit" do
@app.expects(:exit)
- RDoc.expects(:usage).returns(true)
@app.handle_help(nil)
end
diff --combined spec/unit/util/log/destinations_spec.rb
index 468702f,710a517..b84c2ab
--- a/spec/unit/util/log/destinations_spec.rb
+++ b/spec/unit/util/log/destinations_spec.rb
@@@ -1,6 -1,6 +1,6 @@@
#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
require 'puppet/util/log'
@@@ -22,3 -22,16 +22,16 @@@ describe Puppet::Util::Log.desttypes[:r
dest.handle "my log"
end
end
+
+
+ describe Puppet::Util::Log.desttypes[:file] do
+ before do
+ File.stubs(:open) # prevent actually creating the file
+ @class = Puppet::Util::Log.desttypes[:file]
+ end
+
+ it "should default to autoflush false" do
+ @class.new('/tmp/log').autoflush.should == false
+ end
+ end
+
diff --combined spec/unit/util/log_spec.rb
index a6f1173,4a30d50..29df078
--- a/spec/unit/util/log_spec.rb
+++ b/spec/unit/util/log_spec.rb
@@@ -7,7 -7,7 +7,7 @@@ require 'puppet/util/log
describe Puppet::Util::Log do
it "should write a given message to the specified destination" do
arraydest = []
- Puppet::Util::Log.newdestination(arraydest)
+ Puppet::Util::Log.newdestination(Puppet::Test::LogCollector.new(arraydest))
Puppet::Util::Log.new(:level => :notice, :message => "foo")
message = arraydest.last.message
message.should == "foo"
@@@ -87,7 -87,7 +87,7 @@@
it "should flush the log queue when the first destination is specified" do
Puppet::Util::Log.close_all
Puppet::Util::Log.expects(:flushqueue)
- Puppet::Util::Log.newdestination([])
+ Puppet::Util::Log.newdestination(:console)
end
it "should convert the level to a symbol if it's passed in as a string" do
@@@ -136,6 -136,11 +136,11 @@@
Puppet::Util::Log.new(:level => "notice", :message => :foo)
end
+ it "should update Log autoflush when Puppet[:autoflush] is set" do
+ Puppet::Util::Log.expects(:autoflush=).once.with(true)
+ Puppet[:autoflush] = true
+ end
+
it "should have a method for determining if a tag is present" do
Puppet::Util::Log.new(:level => "notice", :message => :foo).should respond_to(:tagged?)
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list