summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-15 13:19:11 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-15 15:14:29 -0700
commitc00e03d41b0bd1174b51eddf5e593aec3bbdd84d (patch)
treece599b6bb4b6e5633801efcbb041380a6def2d4a /lib/puppet
parentdca1f077dd7a818aee447222a7649742f2b1575f (diff)
downloadpuppet-c00e03d41b0bd1174b51eddf5e593aec3bbdd84d.tar.gz
puppet-c00e03d41b0bd1174b51eddf5e593aec3bbdd84d.tar.xz
puppet-c00e03d41b0bd1174b51eddf5e593aec3bbdd84d.zip
(#7059) Set the CA location using option hooks.
Now that we support option hooks, we can use those to set the CA location rather than open-coding each chunk of support. As a side benefit we also set the CA location for inherited actions, as we should. Reviewed-By: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/face/certificate.rb28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/puppet/face/certificate.rb b/lib/puppet/face/certificate.rb
index 77e80f099..4c2950fb3 100644
--- a/lib/puppet/face/certificate.rb
+++ b/lib/puppet/face/certificate.rb
@@ -2,24 +2,16 @@ require 'puppet/face/indirector'
require 'puppet/ssl/host'
Puppet::Face::Indirector.define(:certificate, '0.0.1') do
- # REVISIT: This should use a pre-invoke hook to run the common code that
- # needs to happen before we invoke any action; that would be much nicer than
- # the "please repeat yourself" stuff found in here right now.
- #
- # option "--ca-location LOCATION" do
- # type [:whatever, :location, :symbols]
- # hook :before do |value|
- # Puppet::SSL::Host.ca_location = value
- # end
- # end
- #
- # ...but should I pass the arguments as well?
- # --daniel 2011-04-05
- option "--ca-location LOCATION"
+ option "--ca-location LOCATION" do
+ before_action do |action, args, options|
+ Puppet::SSL::Host.ca_location = options[:ca_location].to_sym
+ end
+ end
action :generate do
+ summary "Generate a new Certificate Signing Request for HOST"
+
when_invoked do |name, options|
- Puppet::SSL::Host.ca_location = options[:ca_location].to_sym
host = Puppet::SSL::Host.new(name)
host.generate_certificate_request
host.certificate_request.class.indirection.save(host.certificate_request)
@@ -27,8 +19,9 @@ Puppet::Face::Indirector.define(:certificate, '0.0.1') do
end
action :list do
+ summary "List all Certificate Signing Requests"
+
when_invoked do |options|
- Puppet::SSL::Host.ca_location = options[:ca_location].to_sym
Puppet::SSL::Host.indirection.search("*", {
:for => :certificate_request,
}).map { |h| h.inspect }
@@ -36,8 +29,9 @@ Puppet::Face::Indirector.define(:certificate, '0.0.1') do
end
action :sign do
+ summary "Sign a Certificate Signing Request for HOST"
+
when_invoked do |name, options|
- Puppet::SSL::Host.ca_location = options[:ca_location].to_sym
host = Puppet::SSL::Host.new(name)
host.desired_state = 'signed'
Puppet::SSL::Host.indirection.save(host)