summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-08-29 22:53:44 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-08-29 22:53:44 +0000
commit8a99636cb9f048bfbbd8b956a15ec84ae68d34f0 (patch)
tree6982c84d50c3e195d2cf76286a4112a8d4767533
parentf65563d3d6eddeeac5f1b14e7b2635776be802a7 (diff)
downloadpuppet-8a99636cb9f048bfbbd8b956a15ec84ae68d34f0.tar.gz
puppet-8a99636cb9f048bfbbd8b956a15ec84ae68d34f0.tar.xz
puppet-8a99636cb9f048bfbbd8b956a15ec84ae68d34f0.zip
adding a "--noop" option along with a test case for it
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@607 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xbin/puppetd40
-rwxr-xr-xtest/executables/tc_puppetd.rb28
2 files changed, 51 insertions, 17 deletions
diff --git a/bin/puppetd b/bin/puppetd
index 7b757093e..0579002b2 100755
--- a/bin/puppetd
+++ b/bin/puppetd
@@ -11,6 +11,7 @@
# puppetd [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
# [--ssldir <cert directory>] [-l|--logdest <syslog|<file>|console>]
# [--fqdn <host name>] [-p|--port <port>] [-s|--server <server>]
+# [-w|--waitforcert <seconds>]
#
# = Description
#
@@ -48,7 +49,7 @@
#
# server::
# The remote server from whom to receive the local configuration. Currently
-# must also be the certificate authority. Currently defaults to 'localhost'.
+# must also be the certificate authority. Currently defaults to 'puppet'.
#
# ssldir::
# Where to store and find certificates. Defaults to /etc/puppet/ssl.
@@ -59,6 +60,10 @@
# version::
# Print the puppet version number and exit.
#
+# waitforcert::
+# Have the process wait around, continuously retrying for the certificate
+# each <argument> seconds.
+#
# = Example
#
# puppet -s puppet.domain.com
@@ -90,17 +95,21 @@ result = GetoptLong.new(
[ "--fqdn", "-f", GetoptLong::REQUIRED_ARGUMENT ],
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
[ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--noop", "-n", GetoptLong::NO_ARGUMENT ],
[ "--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
[ "--server", "-s", GetoptLong::REQUIRED_ARGUMENT ],
[ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
[ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
- [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT ],
+ [ "--waitforcert", "-w", GetoptLong::REQUIRED_ARGUMENT ]
)
-server = "localhost"
+server = "puppet"
fqdn = nil
args = {}
+waitforcert = false
+
begin
result.each { |opt,arg|
case opt
@@ -118,6 +127,8 @@ begin
Puppet[:loglevel] = :info
when "--debug"
Puppet[:loglevel] = :debug
+ when "--noop"
+ Puppet[:noop] = true
when "--ssldir"
Puppet[:ssldir] = arg
when "--fqdn"
@@ -134,6 +145,8 @@ begin
else
$stderr.puts "Invalid log destination %s" % arg
end
+ when "--waitforcert"
+ waitforcert = arg
end
}
rescue GetoptLong::InvalidOption => detail
@@ -159,14 +172,21 @@ end
client = Puppet::Client::MasterClient.new(args)
unless client.readcert
- begin
- while ! client.requestcert do
- Puppet.notice "Did not receive certificate"
- sleep 60
+ if waitforcert
+ begin
+ while ! client.requestcert do
+ Puppet.notice "Did not receive certificate"
+ sleep waitforcert
+ end
+ rescue => detail
+ Puppet.err "Could not request certificate: %s" % detail.to_s
+ exit(23)
+ end
+ else
+ unless client.requestcert
+ Puppet.notice "No certificates; exiting"
+ exit(1)
end
- rescue => detail
- Puppet.err "Could not request certificate: %s" % detail.to_s
- exit(23)
end
end
diff --git a/test/executables/tc_puppetd.rb b/test/executables/tc_puppetd.rb
index 0a0556c41..238133856 100755
--- a/test/executables/tc_puppetd.rb
+++ b/test/executables/tc_puppetd.rb
@@ -73,14 +73,15 @@ class TestPuppetDExe < Test::Unit::TestCase
def test_normalstart
file = "/tmp/testingmanifest.pp"
+ mkfile = "/tmp/puppetdtesting"
File.open(file, "w") { |f|
- f.puts '
-file { "/tmp/puppetdtesting": create => true, mode => 755 }
-'
+ f.puts %{
+file { "#{mkfile}": create => true, mode => 755 }
+}
}
@@tmpfiles << file
- @@tmpfiles << "/tmp/puppetdtesting"
+ @@tmpfiles << mkfile
port = 8235
startmaster(file, port)
output = nil
@@ -89,15 +90,28 @@ file { "/tmp/puppetdtesting": create => true, mode => 755 }
client = Puppet::Client.new(:Server => "localhost")
fqdn = client.fqdn.sub(/^\w+\./, "testing.")
assert_nothing_raised {
- output = %x{puppetd --fqdn #{fqdn} --port #{port} --ssldir #{ssldir} --server localhost}.chomp
+ output = %x{puppetd --verbose --fqdn #{fqdn} --port #{port} --ssldir #{ssldir} --server localhost}.chomp
}
sleep 1
assert($? == 0, "Puppetd exited with code %s" % $?)
#puts output
- assert_equal("", output, "Puppetd produced output %s" % output)
+ #assert_equal("", output, "Puppetd produced output %s" % output)
- assert(FileTest.exists?("/tmp/puppetdtesting"),
+ assert(FileTest.exists?(mkfile),
"Failed to create config'ed file")
+
+ # now verify that --noop works
+ File.unlink(mkfile)
+
+ assert_nothing_raised {
+ output = %x{puppetd --noop --fqdn #{fqdn} --port #{port} --ssldir #{ssldir} --server localhost}.chomp
+ }
+ sleep 1
+ assert($? == 0, "Puppetd exited with code %s" % $?)
+
+ assert(! FileTest.exists?(mkfile),
+ "Noop created config'ed file")
+
stopmaster
end
end