Please review pull request #416: (#8701) waitforcert param configurable for puppet agent opened by (kelseyhightower)

Description:

Allow configuring the default value (120 seconds) for the waitforcert
parameter through configuration.

  • Opened: Fri Jan 27 13:09:08 UTC 2012
  • Based on: puppetlabs:master (7630671ec38d754464898ba3ad68caab144dc89b)
  • Requested merge: kelseyhightower:ticket/master/8701_waitforcert_param_configurable_for_puppet_agent (447796d8ac4432a3487dfddeb4a87750fbcfe622)

Diff follows:

diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index 687ebeb..191b3bf 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -399,7 +399,7 @@ def setup_listen
 
   def setup_host
     @host = Puppet::SSL::Host.new
-    waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : 120)
+    waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : Puppet[:waitforcert])
     cert = @host.wait_for_cert(waitforcert) unless options[:fingerprint]
   end
 
diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb
index d0b9387..22bcc8b 100644
--- a/lib/puppet/application/device.rb
+++ b/lib/puppet/application/device.rb
@@ -78,7 +78,7 @@ def help
 
 DESCRIPTION
 -----------
-Once the client has a signed certificate for a given remote device, it will 
+Once the client has a signed certificate for a given remote device, it will
 retrieve its configuration and apply it.
 
 USAGE NOTES
@@ -148,7 +148,7 @@ def help
 
 COPYRIGHT
 ---------
-Copyright (c) 2011 Puppet Labs, LLC 
+Copyright (c) 2011 Puppet Labs, LLC
 Licensed under the Apache 2.0 License
       HELP
     end
@@ -217,7 +217,7 @@ def setup_logs
 
   def setup_host
     @host = Puppet::SSL::Host.new
-    waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : 120)
+    waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : Puppet[:waitforcert])
     cert = @host.wait_for_cert(waitforcert)
   end
 
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 57f9f42..213a8f0 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -730,7 +730,12 @@ module Puppet
       Your puppet master needs to support compression (usually by activating some settings in a reverse-proxy
       in front of the puppet master, which rules out webrick).
       It is harmless to activate this settings if your master doesn't support
-      compression, but if it supports it, this setting might reduce performance on high-speed LANs."]
+      compression, but if it supports it, this setting might reduce performance on high-speed LANs."],
+    :waitforcert => [120, # 2 minutes
+      "The time interval, specified in seconds, 'puppet agent' should connect to the server
+      and ask it to sign a certificate request. This is useful for the initial setup of a
+      puppet client. You can turn off waiting for certificates by specifying a time of 0."
+    ]
   )
 
   setdefaults(:inspect,
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index e10f10a..d8baa76 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -83,6 +83,12 @@
 
       @puppetd.options[:fingerprint].should be_false
     end
+
+    it "should init waitforcert to nil" do
+      @puppetd.preinit
+
+      @puppetd.options[:waitforcert].should be_nil
+    end
   end
 
   describe "when handling options" do
@@ -124,6 +130,12 @@
       @puppetd.setup_host
     end
 
+    it "should use the waitforcert setting when checking for a signed certificate" do
+      Puppet[:waitforcert] = 10
+      Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(10)
+      @puppetd.setup_host
+    end
+
     it "should set the log destination with --logdest" do
       @puppetd.options.stubs(:[]=).with { |opt,val| opt == :setdest }
       Puppet::Log.expects(:newdestination).with("console")
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb
index 43048fb..3135ff3 100755
--- a/spec/unit/application/device_spec.rb
+++ b/spec/unit/application/device_spec.rb
@@ -45,6 +45,12 @@
 
       @device.preinit
     end
+
+    it "should init waitforcert to nil" do
+      @device.preinit
+
+      @device.options[:waitforcert].should be_nil
+    end
   end
 
   describe "when handling options" do
@@ -81,6 +87,12 @@
       @device.setup_host
     end
 
+    it "should use the waitforcert setting when checking for a signed certificate" do
+      Puppet[:waitforcert] = 10
+      Puppet::SSL::Host.any_instance.expects(:wait_for_cert).with(10)
+      @device.setup_host
+    end
+
     it "should set the log destination with --logdest" do
       @device.options.stubs(:[]=).with { |opt,val| opt == :setdest }
       Puppet::Log.expects(:newdestination).with("console")

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to