diff options
Diffstat (limited to 'lib/puppet/client/master.rb')
-rw-r--r-- | lib/puppet/client/master.rb | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb index 9ea24d502..be7f3748d 100644 --- a/lib/puppet/client/master.rb +++ b/lib/puppet/client/master.rb @@ -1,5 +1,10 @@ # The client for interacting with the puppetmaster config server. class Puppet::Client::MasterClient < Puppet::Client + Puppet.setdefaults("puppetd", + [:puppetdlockfile, "$statedir/puppetdlock", + "A lock file to temporarily stop puppetd from doing anything."] + ) + @drivername = :Master def self.facts @@ -79,6 +84,19 @@ class Puppet::Client::MasterClient < Puppet::Client @cachefile end + # Disable running the configuration. + def disable + Puppet.notice "Disabling puppetd" + unless FileTest.exists? File.dirname(Puppet[:puppetdlockfile]) + Puppet.recmkdir(File.dirname(Puppet[:puppetdlockfile])) + end + begin + File.open(Puppet[:puppetdlockfile], "w") { |f| f.puts ""; f.flush } + rescue => detail + raise Puppet::Error, "Could not lock puppetd: %s" % detail + end + end + # Initialize and load storage def dostorage begin @@ -96,6 +114,14 @@ class Puppet::Client::MasterClient < Puppet::Client end end + # Enable running again. + def enable + Puppet.notice "Enabling puppetd" + if FileTest.exists? Puppet[:puppetdlockfile] + File.unlink(Puppet[:puppetdlockfile]) + end + end + # Check whether our configuration is up to date def fresh? unless defined? @configstamp @@ -227,8 +253,13 @@ class Puppet::Client::MasterClient < Puppet::Client # The code that actually runs the configuration. def run - self.getconfig - self.apply + if FileTest.exists? Puppet[:puppetdlockfile] + Puppet.notice "%s exists; skipping configuration run" % + Puppet[:puppetdlockfile] + else + self.getconfig + self.apply + end end def setclasses(ary) |