summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2010-07-12 16:23:35 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-13 23:09:36 -0700
commit793d7b7cfd2bb1d61a0c0686dc1f8533c8ab13d9 (patch)
tree105066086bb1b74416e060d887d90509f088492f /lib/puppet/application
parent2edf7fe968ac3d8af9865f65100940747c1fa894 (diff)
downloadpuppet-793d7b7cfd2bb1d61a0c0686dc1f8533c8ab13d9.tar.gz
puppet-793d7b7cfd2bb1d61a0c0686dc1f8533c8ab13d9.tar.xz
puppet-793d7b7cfd2bb1d61a0c0686dc1f8533c8ab13d9.zip
[#4213] -o option for setting onetime now works properly
When onetime was moved to global defaults, it broke the option handler using it in agent to manage waitforcert length. Additionally, it caused --onetime and -o to behave differently. This patch removes the ordinary option handler defined in agent and moves the logic for waitforcert to the one location it's used.
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/agent.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index b90bdd484..f0e7f4d8f 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -5,7 +5,7 @@ class Puppet::Application::Agent < Puppet::Application
should_parse_config
run_mode :agent
- attr_accessor :explicit_waitforcert, :args, :agent, :daemon, :host
+ attr_accessor :args, :agent, :daemon, :host
def preinit
# Do an initial trap, so that cancels don't get a stack trace.
@@ -15,7 +15,7 @@ class Puppet::Application::Agent < Puppet::Application
end
{
- :waitforcert => 120, # Default to checking for certs every 5 minutes
+ :waitforcert => nil,
:detailed_exitcodes => false,
:verbose => false,
:debug => false,
@@ -32,7 +32,6 @@ class Puppet::Application::Agent < Puppet::Application
options[opt] = val
end
- @explicit_waitforcert = false
@args = {}
require 'puppet/daemon'
@daemon = Puppet::Daemon.new
@@ -62,11 +61,6 @@ class Puppet::Application::Agent < Puppet::Application
options[:client] = false
end
- option("--onetime", "-o") do |arg|
- Puppet[:onetime] = true
- options[:waitforcert] = 0 unless @explicit_waitforcert
- end
-
option("--detailed-exitcodes") do |arg|
options[:detailed_exitcodes] = true
end
@@ -83,7 +77,6 @@ class Puppet::Application::Agent < Puppet::Application
option("--waitforcert WAITFORCERT", "-w") do |arg|
options[:waitforcert] = arg.to_i
- @explicit_waitforcert = true
end
option("--port PORT","-p") do |arg|
@@ -149,7 +142,6 @@ class Puppet::Application::Agent < Puppet::Application
options[:verbose] = true
Puppet[:onetime] = true
options[:detailed_exitcodes] = true
- options[:waitforcert] = 0 unless @explicit_waitforcert
end
# Handle the logging settings.
@@ -196,6 +188,12 @@ class Puppet::Application::Agent < Puppet::Application
@daemon.server = server
end
+ def setup_host
+ @host = Puppet::SSL::Host.new
+ waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : 120)
+ cert = @host.wait_for_cert(waitforcert) unless options[:fingerprint]
+ end
+
def setup
setup_test if options[:test]
@@ -252,8 +250,7 @@ class Puppet::Application::Agent < Puppet::Application
# waitforcert happens.
@daemon.daemonize if Puppet[:daemonize]
- @host = Puppet::SSL::Host.new
- cert = @host.wait_for_cert(options[:waitforcert]) unless options[:fingerprint]
+ setup_host
@objects = []