diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-15 21:29:18 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-15 21:29:18 -0600 |
commit | 9290cc89a2206fb5204578f8e91208857a48b147 (patch) | |
tree | 60eccb1ac688e6a9ca618155cdc141a23e6f6498 /lib/puppet | |
parent | ffb4c2dbc7314b364d25e4f7be599ef05b767b44 (diff) | |
download | puppet-9290cc89a2206fb5204578f8e91208857a48b147.tar.gz puppet-9290cc89a2206fb5204578f8e91208857a48b147.tar.xz puppet-9290cc89a2206fb5204578f8e91208857a48b147.zip |
Modifying how default resources are created; they are now
added to the configuration by the master client, rather than
by the creating types.
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/network/client/master.rb | 21 | ||||
-rwxr-xr-x | lib/puppet/type/pfilebucket.rb | 8 | ||||
-rwxr-xr-x | lib/puppet/type/schedule.rb | 25 |
3 files changed, 26 insertions, 28 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 2b0c99d33..691681f9e 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -49,15 +49,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase } end - # Add our default resources to the configuration. - def add_default_resources(configuration) - # First create the default scheduling objects - Puppet::Type.type(:schedule).add_default_schedules(configuration) - - # And filebuckets - Puppet::Type.type(:filebucket).add_default_filebucket(configuration) - end - # Cache the config def cache(text) Puppet.info "Caching configuration at %s" % self.cachefile @@ -558,6 +549,18 @@ class Puppet::Network::Client::Master < Puppet::Network::Client private + # Add our default resources to the configuration. + def add_default_resources(configuration) + # These are the only two resource types with default resources. + # We should probably iterate across all of them, but I think that's + # unnecessarily expensive at this point. + [:schedule, :filebucket].each do |resource_type| + Puppet::Type.type(resource_type).create_default_resources.each do |resource| + configuration.add_resource(resource) unless configuration.resource(resource_type, resource.title) + end + end + end + # Use our cached config, optionally specifying whether this is # necessary because of a failure. def use_cached_config(because_of_failure = false) diff --git a/lib/puppet/type/pfilebucket.rb b/lib/puppet/type/pfilebucket.rb index 065d07fcb..5ce81858b 100755 --- a/lib/puppet/type/pfilebucket.rb +++ b/lib/puppet/type/pfilebucket.rb @@ -64,11 +64,9 @@ module Puppet end # Create a default filebucket. - def self.add_default_bucket(configuration) - unless configuration.resource(:filebucket, "puppet") - Puppet.debug "Creating default local filebucket" - configuration.create :filebucket, :name => "puppet", :path => Puppet[:clientbucketdir] - end + def self.create_default_resources + Puppet.debug "Creating default local filebucket" + self.create :name => "puppet", :path => Puppet[:clientbucketdir] end def self.instances diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index 9772762bb..72d649584 100755 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -311,27 +311,24 @@ module Puppet [] end - def self.add_default_schedules(configuration) + def self.create_default_schedules Puppet.debug "Creating default schedules" resources = [] # Create our default schedule - unless configuration.resource(:schedule, "puppet") - configuration.create(:schedule, - :name => "puppet", - :period => :hourly, - :repeat => "2" - ) - end + resources << self.create( + :name => "puppet", + :period => :hourly, + :repeat => "2" + ) # And then one for every period @parameters.find { |p| p.name == :period }.values.each { |value| - unless configuration.resource(:schedule, value.to_s) - configuraiton.create(:schedule, - :name => value.to_s, - :period => value - ) - end + resources << self.create(:schedule, + :name => value.to_s, + :period => value + ) } + resources end def match?(previous = nil, now = nil) |