summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-14 00:14:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-14 00:14:56 +0000
commit19942633b69f04c6789ef08a04d434024e1bc334 (patch)
treeb0890fdaf0a0c4a756ebce9604a516d250bc49f9 /lib/puppet
parent798b3be4cf1d703cd8559414922b296600db9b47 (diff)
downloadpuppet-19942633b69f04c6789ef08a04d434024e1bc334.tar.gz
puppet-19942633b69f04c6789ef08a04d434024e1bc334.tar.xz
puppet-19942633b69f04c6789ef08a04d434024e1bc334.zip
Adding --enable/--disable locking for puppetd. You can now disable puppetd from running by creating a lock file, which is useful if you are testing a configuration and want puppetd not to run for a bit.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@908 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/client/master.rb35
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)