summaryrefslogtreecommitdiffstats
path: root/lib/puppet/client/master.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-18 20:41:54 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-18 20:41:54 +0000
commitb3ea53cd99df84a93fe2f093d2224e711f49e5dd (patch)
tree848e3b2bc03865709e4b6e38f1536ebec99ba8b0 /lib/puppet/client/master.rb
parent93771b7935e544630c3416fda928a3820c615df2 (diff)
downloadpuppet-b3ea53cd99df84a93fe2f093d2224e711f49e5dd.tar.gz
puppet-b3ea53cd99df84a93fe2f093d2224e711f49e5dd.tar.xz
puppet-b3ea53cd99df84a93fe2f093d2224e711f49e5dd.zip
Adding a lot of structure to puppet.rb to make it easier to manage multiple objects in a single process, including making it easy to add threads. Added some testing for all of that.
Also added a "runner" server, meant to be started within puppetd, so that clients can have runs triggered from a central host git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1212 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/client/master.rb')
-rw-r--r--lib/puppet/client/master.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb
index b1da61405..9194b86be 100644
--- a/lib/puppet/client/master.rb
+++ b/lib/puppet/client/master.rb
@@ -25,6 +25,12 @@ class Puppet::Client::MasterClient < Puppet::Client
attr_accessor :objects
+ class << self
+ # Puppetd should only have one instance running, and we need a way
+ # to retrieve it.
+ attr_accessor :instance
+ end
+
def self.facts
facts = {}
Facter.each { |name,fact|
@@ -39,7 +45,7 @@ class Puppet::Client::MasterClient < Puppet::Client
end
# This method actually applies the configuration.
- def apply
+ def apply(tags = nil, ignoreschedules = false)
dostorage()
unless defined? @objects
raise Puppet::Error, "Cannot apply; objects not defined"
@@ -52,6 +58,14 @@ class Puppet::Client::MasterClient < Puppet::Client
transaction = @objects.evaluate
transaction.toplevel = true
+ if tags
+ transaction.tags = tags
+ end
+
+ if ignoreschedules
+ transaction.ignoreschedules = true
+ end
+
begin
transaction.evaluate
rescue Puppet::Error => detail
@@ -267,6 +281,13 @@ class Puppet::Client::MasterClient < Puppet::Client
return @objects
end
+ # Just so we can specify that we are "the" instance.
+ def initialize(*args)
+ super
+
+ self.class.instance = self
+ end
+
# Make sure only one client runs at a time, and make sure only one thread
# runs at a time. However, this does not lock local clients -- you could have
# as many separate puppet scripts running as you want.
@@ -308,7 +329,7 @@ class Puppet::Client::MasterClient < Puppet::Client
end
# The code that actually runs the configuration.
- def run
+ def run(tags = nil, ignoreschedules = false)
if pid = locked?
t = ""
if pid == true
@@ -325,7 +346,7 @@ class Puppet::Client::MasterClient < Puppet::Client
Puppet.notice "Starting configuration run"
end
benchmark(:notice, "Finished configuration run") do
- self.apply
+ self.apply(tags, ignoreschedules)
end
end
end