From 16b2311256a142a69cb9ddadf29eea804b281e1c Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Tue, 5 Apr 2011 16:19:01 +1000 Subject: (#6885) puppet agent fingerprint requires --verbose to return a value. Always output the fingerprint to STDOUT, no matter what loglevel is used, as that's the whole purpose of the comment. Having to specify --verbose in addition to --fingerprint to get the finger is nonsensical. Update the spec test to stub @puppet puts, instead of the Puppet.logging facilities. Reviewed-by: Daniel Pittman --- lib/puppet/application/agent.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 3749241f8..53e083232 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -98,7 +98,7 @@ class Puppet::Application::Agent < Puppet::Application unless fingerprint = cert.fingerprint(options[:digest]) raise ArgumentError, "Could not get fingerprint for digest '#{options[:digest]}'" end - Puppet.notice fingerprint + puts fingerprint end def onetime -- cgit From cd4fe148aae923f1167a3db450b64ead87418018 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 2 Jun 2011 16:16:12 -0700 Subject: (#2128) Add the ability to specify a node name The setting node_name_value may now be used for 'puppet apply' or 'puppet agent' to specify the name for the node. This will not affect the certificate used by the node, and the node will still be authenticated based on its certname. The default value for node_name_value is the certname. This is useful for eg. EC2 nodes whose random hostnames cannot be easily used to classify them. Paired-With: Jacob Helwig --- lib/puppet/application/apply.rb | 8 ++++---- lib/puppet/configurer.rb | 4 ++-- lib/puppet/configurer/fact_handler.rb | 2 +- lib/puppet/defaults.rb | 1 + lib/puppet/transaction/report.rb | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 7f0b95a89..3f423a4c4 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -85,13 +85,13 @@ class Puppet::Application::Apply < Puppet::Application end # Collect our facts. - unless facts = Puppet::Node::Facts.find(Puppet[:certname]) - raise "Could not find facts for #{Puppet[:certname]}" + unless facts = Puppet::Node::Facts.find(Puppet[:node_name_value]) + raise "Could not find facts for #{Puppet[:node_name_value]}" end # Find our Node - unless node = Puppet::Node.find(Puppet[:certname]) - raise "Could not find node #{Puppet[:certname]}" + unless node = Puppet::Node.find(Puppet[:node_name_value]) + raise "Could not find node #{Puppet[:node_name_value]}" end # Merge in the facts. diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index 9f68ca499..d0251de82 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -220,7 +220,7 @@ class Puppet::Configurer def retrieve_catalog_from_cache(fact_options) result = nil @duration = thinmark do - result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true)) + result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_terminus => true)) end Puppet.notice "Using cached catalog" result @@ -233,7 +233,7 @@ class Puppet::Configurer def retrieve_new_catalog(fact_options) result = nil @duration = thinmark do - result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_cache => true)) + result = Puppet::Resource::Catalog.find(Puppet[:node_name_value], fact_options.merge(:ignore_cache => true)) end result rescue SystemExit,NoMemoryError diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 075a59458..4d80e17b6 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -16,7 +16,7 @@ module Puppet::Configurer::FactHandler # compile them and then "cache" them on the server. begin reload_facter - Puppet::Node::Facts.find(Puppet[:certname]) + Puppet::Node::Facts.find(Puppet[:node_name_value]) rescue SystemExit,NoMemoryError raise rescue Exception => detail diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 2a1ded592..17c2850e5 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -486,6 +486,7 @@ module Puppet ) setdefaults(:agent, + :node_name_value => ["$certname", "The name of the node."], :localconfig => { :default => "$statedir/localconfig", :owner => "root", :mode => 0660, diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 16fee42ae..841c56968 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -67,7 +67,7 @@ class Puppet::Transaction::Report @logs = [] @resource_statuses = {} @external_times ||= {} - @host = Puppet[:certname] + @host = Puppet[:node_name_value] @time = Time.now @kind = kind @report_format = 2 -- cgit From c629958fb45f9ae3581f01835bf89654dd7967b7 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 2 Jun 2011 16:23:34 -0700 Subject: (#2128) Get facts before retrieving catalog Retrieving a catalog and getting the facts to submit with the catalog request are distinct operations, and should be done separately. This is also to prepare for adding the ability to determine the node name based on a fact, in which case the node name needs to be determined before it is used for either the catalog or the report. Paired-With: Jacob Helwig --- lib/puppet/configurer.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index d0251de82..596d2dc53 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -84,16 +84,8 @@ class Puppet::Configurer end # Get the remote catalog, yo. Returns nil if no catalog can be found. - def retrieve_catalog - if Puppet::Resource::Catalog.indirection.terminus_class == :rest - # This is a bit complicated. We need the serialized and escaped facts, - # and we need to know which format they're encoded in. Thus, we - # get a hash with both of these pieces of information. - fact_options = facts_for_uploading - else - fact_options = {} - end - + def retrieve_catalog(fact_options) + fact_options ||= {} # First try it with no cache, then with the cache. unless (Puppet[:use_cached_catalog] and result = retrieve_catalog_from_cache(fact_options)) or result = retrieve_new_catalog(fact_options) if ! Puppet[:usecacheonfailure] @@ -130,13 +122,20 @@ class Puppet::Configurer Puppet.err "Failed to prepare catalog: #{detail}" end + if Puppet::Resource::Catalog.indirection.terminus_class == :rest + # This is a bit complicated. We need the serialized and escaped facts, + # and we need to know which format they're encoded in. Thus, we + # get a hash with both of these pieces of information. + fact_options = facts_for_uploading + end + options[:report] ||= Puppet::Transaction::Report.new("apply") report = options[:report] Puppet::Util::Log.newdestination(report) if catalog = options[:catalog] options.delete(:catalog) - elsif ! catalog = retrieve_catalog + elsif ! catalog = retrieve_catalog(fact_options) Puppet.err "Could not retrieve catalog; skipping run" return end -- cgit From 1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 2 Jun 2011 16:24:16 -0700 Subject: (#2128) Add support for setting node name based on a fact This adds the node_name_fact setting, which specifies a fact to use to determine the node name. This allows dynamically determining the node name without having to modify puppet.conf or command line options. Using this setting requires modifying auth.conf to allow nodes to request catalogs not matching their certnames. For example, this would allow any authenticated node to retrieve any catalog: # $confdir/auth.conf path ~ /catalog/.+ allow * The node_name_fact and node_name_value options are mutually exclusive, because it is ambiguous which setting should take precedence. Paired-With: Jacob Helwig --- lib/puppet/application/apply.rb | 5 +++++ lib/puppet/configurer/fact_handler.rb | 7 ++++++- lib/puppet/defaults.rb | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 3f423a4c4..717935640 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -89,6 +89,11 @@ class Puppet::Application::Apply < Puppet::Application raise "Could not find facts for #{Puppet[:node_name_value]}" end + unless Puppet[:node_name_fact].empty? + Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]] + facts.name = Puppet[:node_name_value] + end + # Find our Node unless node = Puppet::Node.find(Puppet[:node_name_value]) raise "Could not find node #{Puppet[:node_name_value]}" diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 4d80e17b6..77bd1e5f1 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -16,7 +16,12 @@ module Puppet::Configurer::FactHandler # compile them and then "cache" them on the server. begin reload_facter - Puppet::Node::Facts.find(Puppet[:node_name_value]) + facts = Puppet::Node::Facts.find(Puppet[:node_name_value]) + unless Puppet[:node_name_fact].empty? + Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]] + facts.name = Puppet[:node_name_value] + end + facts rescue SystemExit,NoMemoryError raise rescue Exception => detail diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 17c2850e5..4502dae16 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -487,6 +487,14 @@ module Puppet setdefaults(:agent, :node_name_value => ["$certname", "The name of the node."], + :node_name_fact => { :default => "", + :desc => "The fact to use as the node name.", + :hook => proc do |value| + if !value.empty? and Puppet[:node_name_value] != Puppet[:certname] + raise "Cannot specify both the node_name_value and node_name_fact settings" + end + end + }, :localconfig => { :default => "$statedir/localconfig", :owner => "root", :mode => 0660, -- cgit From 5a9998e41bc442ca66ca2ff151750355d2ef6d6f Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Wed, 1 Jun 2011 18:07:40 -0700 Subject: (#7773, 7776, 7764) Several help template tweaks Per UX review of help output, this commit makes several changes to templates and shared help text: * Change "unknown" to "undocumented" * Remove copyright from short help * Point readers to the man pages (issue 7773) * Remove examples from short help (issue 7776) * Remove summary from short help and make it a fallback for description * Edit common option summaries to fit on a single 80-col line --- lib/puppet/face/help/action.erb | 16 ++++------------ lib/puppet/face/help/face.erb | 17 +++++------------ lib/puppet/face/help/man.erb | 14 +++++++++----- lib/puppet/indirector/face.rb | 2 +- 4 files changed, 19 insertions(+), 30 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/face/help/action.erb b/lib/puppet/face/help/action.erb index c788f34fd..94b935fed 100644 --- a/lib/puppet/face/help/action.erb +++ b/lib/puppet/face/help/action.erb @@ -1,21 +1,16 @@ -<%= action.summary || face.summary || "unknown face..." %> - <% if action.synopsis -%> USAGE: <%= action.synopsis %> <% end -%> -<% if action.short_description -%> -<%= action.short_description.strip %> +<%= action.short_description || action.summary || face.summary || "undocumented face" %> -<% end -%> <% if action.returns -%> RETURNS: <%= action.returns.strip %> <% end -%> OPTIONS: <%# Remove these options once we can introspect them normally. -%> - --mode MODE - The run mode to use (`user`, `agent`, or - `master`). + --mode MODE - The run mode to use (user, agent, or master). --render-as FORMAT - The rendering format to use. --verbose - Whether to log verbosely. --debug - Whether to log debug information. @@ -26,7 +21,7 @@ OPTIONS: option = action.get_option name -%> <%= " " + option.optparse.join(" | ")[0,(optionroom - 1)].ljust(optionroom) + ' - ' -%> <% if !(option.summary) -%> -unknown option... +undocumented option <% elsif option.summary.length <= summaryroom -%> <%= option.summary %> <% @@ -51,7 +46,4 @@ unknown option... end -%> <% end -%> -<% if action.examples -%> -EXAMPLES: -<%= action.examples %> -<% end -%> +See 'puppet man <%= face.name %>' or 'man puppet-<%= face.name %>' for full help. diff --git a/lib/puppet/face/help/face.erb b/lib/puppet/face/help/face.erb index 2a0f0181c..870cc547f 100644 --- a/lib/puppet/face/help/face.erb +++ b/lib/puppet/face/help/face.erb @@ -1,17 +1,12 @@ -<%= face.summary || "unknown face..." %> - <% if face.synopsis -%> USAGE: <%= face.synopsis %> <% end -%> -<% if face.short_description -%> -<%= face.short_description %> +<%= (face.short_description || face.summary || "undocumented subcommand").strip %> -<% end -%> OPTIONS: <%# Remove these options once we can introspect them normally. -%> - --mode MODE - The run mode to use (`user`, `agent`, or - `master`). + --mode MODE - The run mode to use (user, agent, or master). --render-as FORMAT - The rendering format to use. --verbose - Whether to log verbosely. --debug - Whether to log debug information. @@ -22,7 +17,7 @@ OPTIONS: option = face.get_option name -%> <%= " " + option.optparse.join(" | ")[0,(optionroom - 1)].ljust(optionroom) + ' - ' -%> <% if !(option.summary) -%> -unknown option... +undocumented option <% elsif option.summary.length <= summaryroom -%> <%= option.summary %> <% @@ -54,7 +49,7 @@ ACTIONS: action = face.get_action(actionname) -%> <%= action.name.to_s.ljust(padding) + ' ' -%> <% if !(action.summary) -%> -unknown action... +undocumented action <% elsif action.summary.length <= summaryroom -%> <%= action.summary %> <% else @@ -86,6 +81,4 @@ AUTHOR <%= face.authors.join("\n").gsub(/^/, ' * ') %> <% end -%> -COPYRIGHT AND LICENSE: -<%= face.copyright.gsub(/^/, ' ') %> -<%= face.license.gsub(/^/, ' ') %> +See 'puppet man <%= face.name %>' or 'man puppet-<%= face.name %>' for full help. diff --git a/lib/puppet/face/help/man.erb b/lib/puppet/face/help/man.erb index 6f21fe413..0122d974c 100644 --- a/lib/puppet/face/help/man.erb +++ b/lib/puppet/face/help/man.erb @@ -1,4 +1,4 @@ -puppet-<%= face.name %>(8) -- <%= face.summary || "Unknown face." %> +puppet-<%= face.name %>(8) -- <%= face.summary || "Undocumented face." %> <%= '=' * (_erbout.length - 1) %> <% if face.synopsis -%> @@ -32,7 +32,7 @@ configuration options can also be generated by running puppet with and `master`. * --render-as FORMAT: The format in which to render output. The most common formats are `json`, - `s` (string), and `yaml`, but other options such as `dot` are + `s` (string), `yaml`, and `console`, but other options such as `dot` are sometimes available. * --verbose: Whether to log verbosely. @@ -57,12 +57,15 @@ ACTIONS <%= action.synopsis %> <% end -%> -<% if action.description -%> `DESCRIPTION` +<% if action.description -%> <%= action.description.gsub(/^/, ' ') %> -<% end - unique_options = action.options - face.options +<% else -%> + <%= action.summary || "Undocumented action." %> +<% end -%> + +<% unique_options = action.options - face.options unless unique_options.empty? -%> `OPTIONS` @@ -101,6 +104,7 @@ EXAMPLES `<%= action.name.to_s %>` <%= action.examples.strip %> + <% end end -%> diff --git a/lib/puppet/indirector/face.rb b/lib/puppet/indirector/face.rb index 756306a2f..bb8ce2ceb 100644 --- a/lib/puppet/indirector/face.rb +++ b/lib/puppet/indirector/face.rb @@ -2,7 +2,7 @@ require 'puppet/face' class Puppet::Indirector::Face < Puppet::Face option "--terminus TERMINUS" do - summary "The indirector terminus to use for this action." + summary "The indirector terminus to use." description <<-EOT Indirector faces expose indirected subsystems of Puppet. These subsystems are each able to retrieve and alter a specific type of data -- cgit From 17723634875e308b2752efed8ebdfd3db3239215 Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Fri, 3 Jun 2011 10:28:52 -0700 Subject: (#7764, 7775, 7778) Revisions to Faces help text Per UX review of help text, this commit makes several changes over the breadth of the Faces help: * Preface API-only action summaries/descriptions with "API only." (issue #7775) * Provide both CLI and API info in "returns," with the CLI info first. (issue #7778) * Summaries should be sentences. (Add punctuation.) * First sentences of descriptions should reiterate summaries. (Summaries and descriptions should be displayed far enough apart that this isn't a problem.) * Standardize on "subcommand" instead of "face" when talking about the entity you invoke at the command line. (Use "face" when describing API use.) * Fix outdated or clunky text in several faces. --- lib/puppet/face/catalog.rb | 52 ++++++++++++++++---------- lib/puppet/face/catalog/select.rb | 10 ++--- lib/puppet/face/certificate.rb | 31 ++++++++------- lib/puppet/face/certificate_request.rb | 23 ++++++------ lib/puppet/face/certificate_revocation_list.rb | 24 ++++++------ lib/puppet/face/config.rb | 10 ++--- lib/puppet/face/facts.rb | 34 ++++++++++------- lib/puppet/face/file.rb | 8 ++-- lib/puppet/face/file/download.rb | 10 ++--- lib/puppet/face/help.rb | 12 +++--- lib/puppet/face/help/action.erb | 2 +- lib/puppet/face/help/man.erb | 8 ++-- lib/puppet/face/key.rb | 8 ++-- lib/puppet/face/man.rb | 36 +++++++++--------- lib/puppet/face/node.rb | 25 ++++++++----- lib/puppet/face/parser.rb | 9 +++++ lib/puppet/face/plugin.rb | 17 +++++---- lib/puppet/face/report.rb | 16 ++++---- lib/puppet/face/resource.rb | 24 ++++++------ lib/puppet/face/resource_type.rb | 48 ++++++++++++++---------- lib/puppet/face/secret_agent.rb | 30 +++++++-------- lib/puppet/face/status.rb | 21 ++++++----- lib/puppet/indirector/face.rb | 12 +++--- 23 files changed, 261 insertions(+), 209 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb index 13351540a..9bcaa19c6 100644 --- a/lib/puppet/face/catalog.rb +++ b/lib/puppet/face/catalog.rb @@ -6,25 +6,40 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do summary "Compile, save, view, and convert catalogs." description <<-'EOT' - This face primarily interacts with the compiling subsystem. By default, - it compiles a catalog using the default manifest and the hostname from - `certname`, but you can choose to retrieve a catalog from the server by - specifying '--terminus rest'. You can also choose to print any catalog - in 'dot' format (for easy graph viewing with OmniGraffle or Graphviz) - with '--render-as dot'. + This subcommand deals with catalogs, which are compiled per-node artifacts + generated from a set of Puppet manifests. By default, it interacts with the + compiling subsystem and compiles a catalog using the default manifest and + `certname`, but you can change the source of the catalog with the + `--terminus` option. You can also choose to print any catalog in 'dot' + format (for easy graph viewing with OmniGraffle or Graphviz) with + '--render-as dot'. + EOT + short_description <<-'EOT' + This subcommand deals with catalogs, which are compiled per-node artifacts + generated from a set of Puppet manifests. By default, it interacts with the + compiling subsystem and compiles a catalog using the default manifest and + `certname`; use the `--terminus` option to change the source of the catalog. EOT - get_action(:destroy).summary "Invalid for this face." - get_action(:search).summary "Query format unknown; potentially invalid for this face." + get_action(:destroy).summary "Invalid for this subcommand." + get_action(:search).summary "Invalid for this subcommand." + find = get_action(:find) + find.summary "Retrieve the catalog for a node." + find.arguments "" + find.returns <<-'EOT' + A serialized catalog. When used from the Ruby API, returns a + Puppet::Resource::Catalog object. + EOT action(:apply) do - summary "Apply a Puppet::Resource::Catalog object." + summary "Find and apply a catalog." description <<-'EOT' Finds and applies a catalog. This action takes no arguments, but - the source of the catalog can be managed with the --terminus option. + the source of the catalog can be managed with the `--terminus` option. EOT returns <<-'EOT' - A Puppet::Transaction::Report object. + Nothing. When used from the Ruby API, returns a Puppet::Transaction::Report + object. EOT examples <<-'EOT' Apply the locally cached catalog: @@ -71,18 +86,17 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do action(:download) do summary "Download this node's catalog from the puppet master server." description <<-'EOT' - Retrieves a catalog from the puppet master and saves it to the - local yaml cache. The saved catalog can be used in subsequent - catalog actions by specifying '--terminus rest'. - - This action always contacts the puppet master and will ignore + Retrieves a catalog from the puppet master and saves it to the local yaml + cache. This action always contacts the puppet master and will ignore alternate termini. + + The saved catalog can be used in any subsequent catalog action by specifying + '--terminus yaml' for that action. EOT returns "Nothing." notes <<-'EOT' - As termini are singletons, this action has a side effect of - exporting Puppet::Resource::Catalog.indirection.terminus_class = - yaml to the calling context when used with the Ruby Faces API. The + When used from the Ruby API, this action has a side effect of leaving + Puppet::Resource::Catalog.indirection.terminus_class set to yaml. The terminus must be explicitly re-set for subsequent catalog actions. EOT examples <<-'EOT' diff --git a/lib/puppet/face/catalog/select.rb b/lib/puppet/face/catalog/select.rb index d86963e75..de2ca803b 100644 --- a/lib/puppet/face/catalog/select.rb +++ b/lib/puppet/face/catalog/select.rb @@ -1,15 +1,15 @@ # Select and show a list of resources of a given type. Puppet::Face.define(:catalog, '0.0.1') do action :select do - summary "Select and show a list of resources of a given type" + summary "Retrieve a catalog and filter it for resources of a given type." arguments " " returns <<-'EOT' - An array of resource objects excised from a catalog. When used at - the command line, returns a list of resource references (Type[title]). + A list of resource references ("Type[title]"). When used from the API, + returns an array of Puppet::Resource objects excised from a catalog. EOT description <<-'EOT' - Retrieves a catalog for the specified host and returns an array of - resources of the given type. + Retrieves a catalog for the specified host, then searches it for all + resources of the requested type. EOT notes <<-'NOTES' By default, this action will retrieve a catalog from Puppet's compiler diff --git a/lib/puppet/face/certificate.rb b/lib/puppet/face/certificate.rb index cab8817e3..cb0f61e3b 100644 --- a/lib/puppet/face/certificate.rb +++ b/lib/puppet/face/certificate.rb @@ -5,9 +5,9 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do copyright "Puppet Labs", 2011 license "Apache 2 license; see COPYING" - summary "Provide access to the CA for certificate management" + summary "Provide access to the CA for certificate management." description <<-'EOT' - This face interacts with a local or remote Puppet certificate + This subcommand interacts with a local or remote Puppet certificate authority. Currently, its behavior is not a full superset of `puppet cert`; specifically, it is unable to mimic puppet cert's "clean" option, and its "generate" action submits a CSR rather than creating a @@ -15,10 +15,12 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do EOT option "--ca-location LOCATION" do - summary "The certificate authority to query" + summary "The certificate authority to query (local or remote)." description <<-'EOT' Whether to act on the local certificate authority or one provided by a remote puppet master. Allowed values are 'local' and 'remote.' + + This option is required. EOT before_action do |action, args, options| @@ -27,7 +29,7 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do end action :generate do - summary "Generate a new certificate signing request for HOST." + summary "Generate a new certificate signing request." arguments "" returns "Nothing." description <<-'EOT' @@ -55,8 +57,10 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do action :list do summary "List all certificate signing requests." returns <<-'EOT' - An array of CSR object #inspect strings. This output is currently messy, - but does contain the names of nodes requesting certificates. + An array of #inspect output from CSR objects. This output is + currently messy, but does contain the names of nodes requesting + certificates. This action returns #inspect strings even when used + from the Ruby API. EOT when_invoked do |options| @@ -70,8 +74,7 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do summary "Sign a certificate signing request for HOST." arguments "" returns <<-'EOT' - A string that appears to be an x509 certificate, but is actually - not. Retrieve certificates using the `find` action. + A string that appears to be (but isn't) an x509 certificate. EOT examples <<-'EOT' Sign somenode.puppetlabs.lan's certificate: @@ -88,24 +91,24 @@ Puppet::Indirector::Face.define(:certificate, '0.0.1') do # Indirector action doc overrides find = get_action(:find) - find.summary "Retrieve a certificate" + find.summary "Retrieve a certificate." find.arguments "" find.returns <<-'EOT' An x509 SSL certificate. You will usually want to render this as a - string ('--render-as s'). + string (--render-as s). Note that this action has a side effect of caching a copy of the certificate in Puppet's `ssldir`. EOT destroy = get_action(:destroy) - destroy.summary "Delete a local certificate." + destroy.summary "Delete a certificate." destroy.arguments "" destroy.returns "Nothing." destroy.description <<-'EOT' - Deletes a certificate. This action currently only works with a local CA. + Deletes a certificate. This action currently only works on the local CA. EOT - get_action(:search).summary "Invalid for this face." - get_action(:save).summary "Invalid for this face." + get_action(:search).summary "Invalid for this subcommand." + get_action(:save).summary "Invalid for this subcommand." end diff --git a/lib/puppet/face/certificate_request.rb b/lib/puppet/face/certificate_request.rb index 29cf7dc78..12694ba21 100644 --- a/lib/puppet/face/certificate_request.rb +++ b/lib/puppet/face/certificate_request.rb @@ -6,20 +6,20 @@ Puppet::Indirector::Face.define(:certificate_request, '0.0.1') do summary "Manage certificate requests." description <<-'EOT' - Retrieves and submits certificate signing requests (CSRs). Invoke - `search` with a dummy key to retrieve all outstanding CSRs, invoke - `find` with a node certificate name to retrieve a specific request, and - invoke `save` to submit a CSR. + This subcommand retrieves and submits certificate signing requests (CSRs). EOT # Per-action doc overrides - get_action(:destroy).summary "Invalid for this face." + get_action(:destroy).summary "Invalid for this subcommand." get_action(:find).summary "Retrieve a single CSR." get_action(:find).arguments "" get_action(:find).returns <<-'EOT' - A single certificate request. In most cases, you will want to render - this as a string ('--render-as s'). + A single certificate request. When used from the Ruby API, returns a + Puppet::SSL::CertificateRequest object. + + RENDERING ISSUES: In most cases, you will want to render this as a string + ('--render-as s'). EOT get_action(:find).examples <<-'EOT' Retrieve a single CSR from the puppet master's CA: @@ -30,16 +30,17 @@ Puppet::Indirector::Face.define(:certificate_request, '0.0.1') do get_action(:search).summary "Retrieve all outstanding CSRs." get_action(:search).arguments "" get_action(:search).returns <<-'EOT' - An array of certificate request objects. In most cases, you will - want to render this as a string ('--render-as s'). + A list of certificate requests; be sure to to render this as a string + ('--render-as s'). When used from the Ruby API, returns an array of + Puppet::SSL::CertificateRequest objects. EOT get_action(:search).notes "This action always returns all CSRs, but requires a dummy search key." get_action(:search).examples <<-'EOT' - Retrieve all CSRs from the local CA: + Retrieve all CSRs from the local CA (similar to 'puppet cert list'): $ puppet certificate_request search x --terminus ca EOT - get_action(:save).summary "Submit a certificate signing request." + get_action(:save).summary "API only: submit a certificate signing request." get_action(:save).arguments "" end diff --git a/lib/puppet/face/certificate_revocation_list.rb b/lib/puppet/face/certificate_revocation_list.rb index 0525a601f..12ba1f73f 100644 --- a/lib/puppet/face/certificate_revocation_list.rb +++ b/lib/puppet/face/certificate_revocation_list.rb @@ -6,16 +6,18 @@ Puppet::Indirector::Face.define(:certificate_revocation_list, '0.0.1') do summary "Manage the list of revoked certificates." description <<-'EOT' - This face is primarily for retrieving the certificate revocation - list from the CA. Although it exposes search/save/destroy methods, - they shouldn't be used under normal circumstances. + This subcommand is primarily for retrieving the certificate revocation + list from the CA. EOT get_action(:find).summary "Retrieve the certificate revocation list." get_action(:find).arguments "" get_action(:find).returns <<-'EOT' - A certificate revocation list. You will usually want to render this - as a string ('--render-as s'). + A certificate revocation list. When used from the Ruby API: returns an + OpenSSL::X509::CRL object. + + RENDERING ISSUES: this should usually be rendered as a string + ('--render-as s'). EOT get_action(:find).examples <<-'EXAMPLES' Retrieve a copy of the puppet master's CRL: @@ -27,13 +29,11 @@ Puppet::Indirector::Face.define(:certificate_revocation_list, '0.0.1') do get_action(:destroy).arguments "" get_action(:destroy).returns "Nothing." get_action(:destroy).description <<-'EOT' - Deletes the certificate revocation list. This cannot be done over - REST, but it is possible to both delete the locally cached copy of - the CA's CRL and delete the CA's own copy (if running on the CA - machine and invoked with '--terminus ca'). Needless to say, don't do - this unless you know what you're up to. + Deletes the certificate revocation list. This cannot be done over REST, but + it is possible to delete the locally cached copy or (if run from the CA) the + CA's own copy of the CRL. EOT - get_action(:search).summary "Invalid for this face." - get_action(:save).summary "Invalid for this face." + get_action(:search).summary "Invalid for this subcommand." + get_action(:save).summary "Invalid for this subcommand." end diff --git a/lib/puppet/face/config.rb b/lib/puppet/face/config.rb index 6e5bff071..3fce0ed70 100644 --- a/lib/puppet/face/config.rb +++ b/lib/puppet/face/config.rb @@ -7,13 +7,11 @@ Puppet::Face.define(:config, '0.0.1') do summary "Interact with Puppet's configuration options." action(:print) do - summary "Examine Puppet's current configuration options." - arguments "(all |