summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/puppetd33
-rw-r--r--conf/redhat/puppet.spec2
-rw-r--r--lib/puppet/client.rb2
-rw-r--r--lib/puppet/client/ca.rb2
-rwxr-xr-xlib/puppet/daemon.rb41
-rw-r--r--lib/puppet/networkclient.rb9
-rw-r--r--test/client/client.rb2
7 files changed, 49 insertions, 42 deletions
diff --git a/bin/puppetd b/bin/puppetd
index 2b396fc1e..928ae5ba3 100755
--- a/bin/puppetd
+++ b/bin/puppetd
@@ -315,28 +315,29 @@ end
server = nil
unless client.readcert
- if waitforcert
+ # If we don't already have the certificate, then create a client to
+ # request one.
+ caclient = Puppet::Client::CA.new(args)
+ if options[:waitforcert]
begin
- while ! client.requestcert do
+ while ! caclient.requestcert do
Puppet.notice "Did not receive certificate"
- sleep waitforcert
+ sleep options[:waitforcert]
end
rescue => detail
Puppet.err "Could not request certificate: %s" % detail.to_s
exit(23)
end
else
- unless client.requestcert
+ unless caclient.requestcert
Puppet.notice "No certificates; exiting"
exit(1)
end
end
- # Now, because the Net::HTTP object cannot be modified once we've connected,
- # we need to recreate the client with the certs intact
- client = Puppet::Client::MasterClient.new(args)
+ # Now read the new cert in.
unless client.readcert
- PUppet.err "Could not read certificates after retrieving them"
+ Puppet.err "Could not read certificates after retrieving them"
exit(34)
end
end
@@ -410,12 +411,12 @@ if options[:onetime]
else
threads = []
if server
- Puppet.notice "Starting Puppet server version %s" % [Puppet.version]
threads << Thread.new do
begin
server.start
rescue => detail
Puppet.err "Could not start server: %s" % [detail]
+ server.shutdown
exit(1)
end
end
@@ -423,12 +424,14 @@ else
if options[:client]
Puppet.notice "Starting Puppet client version %s" % [Puppet.version]
- begin
- client.start
- rescue => detail
- Puppet.err "Could not start client: %s" % [detail]
- exit(1)
- end
+ begin
+ client.start
+ rescue => detail
+ puts detail.backtrace
+ Puppet.err "Could not start client: %s" % [detail]
+ client.shutdown
+ exit(1)
+ end
end
threads << Thread.new do
diff --git a/conf/redhat/puppet.spec b/conf/redhat/puppet.spec
index 6aa415dd5..b569f56b7 100644
--- a/conf/redhat/puppet.spec
+++ b/conf/redhat/puppet.spec
@@ -4,7 +4,7 @@
Summary: A network tool for managing many disparate systems
Name: puppet
-Version: 0.16.2
+Version: 0.16.3
Release: 1%{?dist}
License: GPL
Group: System Environment/Base
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index 0dd5221ed..7f6ed2592 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -136,6 +136,7 @@ module Puppet
Puppet.notice "Already in shutdown"
else
self.stopping = true
+ rmpidfile()
Puppet::Storage.store
exit
end
@@ -144,7 +145,6 @@ module Puppet
# Start listening for events. We're pretty much just listening for
# timer events here.
def start
- super
# Create our timer
timer = EventLoop::Timer.new(
:interval => Puppet[:runinterval],
diff --git a/lib/puppet/client/ca.rb b/lib/puppet/client/ca.rb
index a7fa71e88..8904c4a13 100644
--- a/lib/puppet/client/ca.rb
+++ b/lib/puppet/client/ca.rb
@@ -1,4 +1,4 @@
-class Puppet::Client::CAClient < Puppet::Client::ProxyClient
+class Puppet::Client::CA < Puppet::Client::ProxyClient
@drivername = :CA
# set up the appropriate interface methods
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index f8d67db95..d2d39eec5 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -204,27 +204,31 @@ module Puppet
return retrieved
end
+ # Remove the pid file
+ def rmpidfile
+ if defined? @pidfile and @pidfile and FileTest.exists?(@pidfile)
+ begin
+ File.unlink(@pidfile)
+ rescue => detail
+ Puppet.err "Could not remove PID file %s: %s" %
+ [@pidfile, detail]
+ end
+ end
+ end
+
# Create the pid file.
def setpidfile
Puppet.config.use(:puppet)
@pidfile = self.pidfile
- if FileTest.exists?(@pidfile) and not defined? $setpidfile
- raise Puppet::Error, "A PID file already exists for #{Puppet.name}
+ if FileTest.exists?(@pidfile)
+ if defined? $setpidfile
+ return
+ else
+ raise Puppet::Error, "A PID file already exists for #{Puppet.name}
at #{@pidfile}. Not starting."
- #Puppet.info "Deleting old pid file"
- #begin
- # File.unlink(@pidfile)
- #rescue Errno::EACCES
- # Puppet.err "Could not delete old PID file; cannot create new one"
- # return
- #end
+ end
end
- #unless FileTest.exists?(Puppet[:rundir])
- # Puppet.recmkdir(Puppet[:rundir])
- # File.chmod(01777, Puppet[:rundir])
- #end
-
Puppet.info "Creating PID file to %s" % @pidfile
begin
File.open(@pidfile, "w") { |f| f.puts $$ }
@@ -238,14 +242,7 @@ at #{@pidfile}. Not starting."
# Shut down our server
def shutdown
# Remove our pid file
- if defined? @pidfile and @pidfile and FileTest.exists?(@pidfile)
- begin
- File.unlink(@pidfile)
- rescue => detail
- Puppet.err "Could not remove PID file %s: %s" %
- [@pidfile, detail]
- end
- end
+ rmpidfile()
# And close all logs
Puppet::Log.close
diff --git a/lib/puppet/networkclient.rb b/lib/puppet/networkclient.rb
index ef3d88179..09c6bc0ab 100644
--- a/lib/puppet/networkclient.rb
+++ b/lib/puppet/networkclient.rb
@@ -44,6 +44,10 @@ module Puppet
# so that they namespaces can define the same methods if
# they want.
newclient = Class.new(self)
+
+ #name = "Puppet::NetworkClient::" + handler.to_s.sub(/^.+::/, '')
+ name = handler.to_s.sub(/^.+::/, '')
+ const_set(name, newclient)
@clients[namespace] = newclient
interface.methods.each { |ary|
@@ -138,7 +142,10 @@ module Puppet
if hash[:Certificate]
self.cert = hash[:Certificate]
else
- Puppet.err "No certificate; running with reduced functionality."
+ unless defined? $nocertwarned
+ Puppet.err "No certificate; running with reduced functionality."
+ $nocertwarned = true
+ end
end
if hash[:Key]
diff --git a/test/client/client.rb b/test/client/client.rb
index 41d55dab2..5bd947657 100644
--- a/test/client/client.rb
+++ b/test/client/client.rb
@@ -86,7 +86,7 @@ class TestClient < Test::Unit::TestCase
# make a new ssldir for it
ca = nil
assert_nothing_raised {
- ca = Puppet::Client::CAClient.new(
+ ca = Puppet::Client::CA.new(
:CA => true, :Local => true
)
ca.requestcert