summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-06-02 15:56:22 -0700
committerMax Martin <max@puppetlabs.com>2011-06-02 15:56:22 -0700
commit4801e10c81264b20c2d35b0d44c10cfb0668d1b9 (patch)
tree3e3024bbd4a46a3ab2af5bf29ec2f3b30db270d7 /lib/puppet/application
parent520cbc0292ec0cf75b6871bb0a4bc12bce506bb0 (diff)
parent4ad88017d3b8b8000325f5165520a6c21b48c469 (diff)
downloadpuppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.tar.gz
puppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.tar.xz
puppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.zip
Merge branch '2.7.x'
* 2.7.x: (40 commits) (#7746) Fix bootstrap issues from #7717 fix. (#7683) Use ronn, when available, to render the output. (#7683) Add a 'man' face and subcommand to Puppet. maint: remove obsolete work-around code from help face. (#7699) Don't duplicate inherited action names on faces. (#7177) Deprecate implicit 'puppet apply' for 2.7.0 (#7717) Layout cleanup for subcommand extraction. #7211: Test unknown options don't shadow unknown actions. #7211: nasty logic error with global Face options taking arguments. #7211: more helpful error messages in various cases. maint: Fix order dependent test failure (#5966) Add support for hostname regular expressions in auth.conf (#7708) Delete extended documentation from configuration reference (#7707) Document signals in puppet agent and puppet master help add puppet master polling step for ticket 7117 (#5318) Always notice changes to manifests when compiling. (#5318) Always notice changes to manifests when compiling. (#7557) Remove Faces Application maint: Fix order dependent spec failure for face indirection (#7690) Don't blow up when listing terminuses available for faces ... Conflicts (resolved manually): acceptance/tests/ticket_7117_broke_env_criteria_authconf.rb
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/agent.rb12
-rw-r--r--lib/puppet/application/face_base.rb28
-rw-r--r--lib/puppet/application/faces.rb126
-rw-r--r--lib/puppet/application/help.rb3
-rw-r--r--lib/puppet/application/man.rb4
-rw-r--r--lib/puppet/application/master.rb10
6 files changed, 47 insertions, 136 deletions
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index 19849c57a..06a158fb3 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -281,6 +281,18 @@ EXAMPLE
$ puppet agent --server puppet.domain.com
+DIAGNOSTICS
+-----------
+
+Puppet agent accepts the following signals:
+
+* SIGHUP:
+ Restart the puppet agent daemon.
+* SIGINT and SIGTERM:
+ Shut down the puppet agent daemon.
+* SIGUSR1:
+ Immediately retrieve and apply configurations from the puppet master.
+
AUTHOR
------
Luke Kanies
diff --git a/lib/puppet/application/face_base.rb b/lib/puppet/application/face_base.rb
index 7a5ce3400..ea5ba4aaf 100644
--- a/lib/puppet/application/face_base.rb
+++ b/lib/puppet/application/face_base.rb
@@ -66,9 +66,9 @@ class Puppet::Application::FaceBase < Puppet::Application
# Now, walk the command line and identify the action. We skip over
# arguments based on introspecting the action and all, and find the first
# non-option word to use as the action.
- action = nil
- index = -1
- until @action or (index += 1) >= command_line.args.length do
+ action_name = nil
+ index = -1
+ until action_name or (index += 1) >= command_line.args.length do
item = command_line.args[index]
if item =~ /^-/ then
option = @face.options.find do |name|
@@ -91,12 +91,16 @@ class Puppet::Application::FaceBase < Puppet::Application
index += 1 # ...so skip the argument.
end
elsif option = find_application_argument(item) then
- index += 1 if (option[:argument] and option[:optional])
+ index += 1 if (option[:argument] and not option[:optional])
else
raise OptionParser::InvalidOption.new(item.sub(/=.*$/, ''))
end
else
- @action = @face.get_action(item.to_sym)
+ # Stash away the requested action name for later, and try to fetch the
+ # action object it represents; if this is an invalid action name that
+ # will be nil, and handled later.
+ action_name = item.to_sym
+ @action = @face.get_action(action_name)
end
end
@@ -104,8 +108,18 @@ class Puppet::Application::FaceBase < Puppet::Application
if @action = @face.get_default_action() then
@is_default_action = true
else
- Puppet.err "#{face.name} does not have a default action, and no action was given"
- Puppet.err Puppet::Face[:help, :current].help(@face.name)
+ # REVISIT: ...and this horror thanks to our log setup, which doesn't
+ # initialize destinations until the setup method, which we will never
+ # reach. We could also just print here, but that is actually a little
+ # uglier and nastier in the long term, in which we should do log setup
+ # earlier if at all possible. --daniel 2011-05-31
+ Puppet::Util::Log.newdestination(:console)
+
+ face = @face.name
+ action = action_name.nil? ? 'default' : "'#{action_name}'"
+ msg = "'#{face}' has no #{action} action. See `puppet help #{face}`."
+ Puppet.err(msg)
+
exit false
end
end
diff --git a/lib/puppet/application/faces.rb b/lib/puppet/application/faces.rb
deleted file mode 100644
index e7fce66b1..000000000
--- a/lib/puppet/application/faces.rb
+++ /dev/null
@@ -1,126 +0,0 @@
-require 'puppet/application'
-require 'puppet/face'
-
-class Puppet::Application::Faces < Puppet::Application
-
- should_parse_config
- run_mode :agent
-
- option("--debug", "-d") do |arg|
- Puppet::Util::Log.level = :debug
- end
-
- option("--verbose", "-v") do
- Puppet::Util::Log.level = :info
- end
-
- def help
- <<-HELP
-puppet-faces(8) -- List available Faces and actions
-========
-
-SYNOPSIS
---------
-Lists the available subcommands (with applicable terminuses and/or actions)
-provided by the Puppet Faces API. This information is automatically read
-from the Puppet code present on the system. By default, the output includes
-all terminuses and actions.
-
-USAGE
------
-puppet faces [-d|--debug] [-v|--verbose] [actions|terminuses]
-
-OPTIONS
--------
-Note that any configuration option valid in the configuration file is also
-a valid long 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'.
-
-* --verbose:
- Sets the log level to "info." This option has no tangible effect at the time
- of this writing.
-
-* --debug:
- Sets the log level to "debug." This option has no tangible effect at the time
- of this writing.
-
-AUTHOR
-------
-Puppet Labs
-
-COPYRIGHT
----------
-Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
-
- HELP
- end
-
- def list(*arguments)
- if arguments.empty?
- arguments = %w{terminuses actions}
- end
- faces.each do |name|
- str = "#{name}:\n"
- if arguments.include?("terminuses")
- begin
- terms = terminus_classes(name.to_sym)
- str << "\tTerminuses: #{terms.join(", ")}\n"
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- $stderr.puts "Could not load terminuses for #{name}: #{detail}"
- end
- end
-
- if arguments.include?("actions")
- begin
- actions = actions(name.to_sym)
- str << "\tActions: #{actions.join(", ")}\n"
- rescue => detail
- puts detail.backtrace if Puppet[:trace]
- $stderr.puts "Could not load actions for #{name}: #{detail}"
- end
- end
-
- print str
- end
- end
-
- attr_accessor :name, :arguments
-
- def main
- list(*arguments)
- end
-
- def setup
- Puppet::Util::Log.newdestination :console
-
- load_applications # Call this to load all of the apps
-
- @arguments = command_line.args
- @arguments ||= []
- end
-
- def faces
- Puppet::Face.faces
- end
-
- def terminus_classes(indirection)
- Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort
- end
-
- def actions(indirection)
- return [] unless face = Puppet::Face[indirection, '0.0.1']
- face.load_actions
- return face.actions.sort { |a, b| a.to_s <=> b.to_s }
- end
-
- def load_applications
- command_line.available_subcommands.each do |app|
- command_line.require_application app
- end
- end
-end
-
diff --git a/lib/puppet/application/help.rb b/lib/puppet/application/help.rb
index 4829a2036..66baa462e 100644
--- a/lib/puppet/application/help.rb
+++ b/lib/puppet/application/help.rb
@@ -1,7 +1,4 @@
require 'puppet/application/face_base'
class Puppet::Application::Help < Puppet::Application::FaceBase
- # Meh. Disable the default behaviour, which is to inspect the
- # string and return that – not so helpful. --daniel 2011-04-11
- def render(result) result end
end
diff --git a/lib/puppet/application/man.rb b/lib/puppet/application/man.rb
new file mode 100644
index 000000000..1ecc4d691
--- /dev/null
+++ b/lib/puppet/application/man.rb
@@ -0,0 +1,4 @@
+require 'puppet/application/face_base'
+
+class Puppet::Application::Man < Puppet::Application::FaceBase
+end
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index a90829ae0..18425c8bc 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -102,6 +102,16 @@ EXAMPLE
-------
puppet master
+DIAGNOSTICS
+-----------
+
+When running as a standalone daemon, puppet master accepts the
+following signals:
+
+* SIGHUP:
+ Restart the puppet master server.
+* SIGINT and SIGTERM:
+ Shut down the puppet master server.
AUTHOR
------