From 793d7b7cfd2bb1d61a0c0686dc1f8533c8ab13d9 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Mon, 12 Jul 2010 16:23:35 -0700 Subject: [#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. --- lib/puppet/application/agent.rb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'lib/puppet/application') 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 = [] -- cgit