summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/network/client/master.rb12
-rw-r--r--lib/puppet/node/catalog.rb21
-rw-r--r--lib/puppet/type/pfile.rb7
-rwxr-xr-xlib/puppet/type/pfilebucket.rb4
-rwxr-xr-xlib/puppet/util/filetype.rb3
5 files changed, 26 insertions, 21 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 6e810b41b..6d1a0235f 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -206,15 +206,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
@running = false
end
- # Make the default objects necessary for function.
- def make_default_resources
- # First create the default scheduling objects
- Puppet::Type.type(:schedule).mkdefaultschedules
-
- # And filebuckets
- Puppet::Type.type(:filebucket).mkdefaultbucket
- end
-
# Mark that we should restart. The Puppet module checks whether we're running,
# so this only gets called if we're in the middle of a run.
def restart
@@ -263,9 +254,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
if self.catalog
- # Make our default schedules and such.
- make_default_resources
-
@catalog.retrieval_duration = duration
Puppet.notice "Starting catalog run" unless @local
benchmark(:notice, "Finished catalog run") do
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index a02d59ae9..c9de2019d 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -260,6 +260,8 @@ class Puppet::Node::Catalog < Puppet::PGraph
# Make sure all of our resources are "finished".
def finalize
+ make_default_resources
+
@resource_table.values.each { |resource| resource.finish }
write_graph(:resources)
@@ -287,6 +289,20 @@ class Puppet::Node::Catalog < Puppet::PGraph
finalize()
end
end
+
+ # Make the default objects necessary for function.
+ def make_default_resources
+ # We have to add the resources to the catalog, or else they won't get cleaned up after
+ # the transaction.
+
+ # First create the default scheduling objects
+ Puppet::Type.type(:schedule).mkdefaultschedules.each { |res| add_resource(res) unless resource(res.ref) }
+
+ # And filebuckets
+ if bucket = Puppet::Type.type(:filebucket).mkdefaultbucket
+ add_resource(bucket)
+ end
+ end
# Create a graph of all of the relationships in our catalog.
def relationship_graph
@@ -367,6 +383,11 @@ class Puppet::Node::Catalog < Puppet::PGraph
end
end
+ # Return an array of all resources.
+ def resources
+ @resource_table.keys
+ end
+
# Add a tag.
def tag(*names)
names.each do |name|
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index bccdaa265..f86e1e273 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -72,12 +72,7 @@ module Puppet
filebucketed files.
"
- defaultto do
- # Make sure the default file bucket exists.
- obj = Puppet::Type.type(:filebucket)["puppet"] ||
- Puppet::Type.type(:filebucket).create(:name => "puppet")
- obj.bucket
- end
+ defaultto { "puppet" }
munge do |value|
# I don't really know how this is happening.
diff --git a/lib/puppet/type/pfilebucket.rb b/lib/puppet/type/pfilebucket.rb
index cf4e5aac3..b268610e9 100755
--- a/lib/puppet/type/pfilebucket.rb
+++ b/lib/puppet/type/pfilebucket.rb
@@ -66,9 +66,9 @@ module Puppet
# Create a default filebucket.
def self.mkdefaultbucket
unless default = self["puppet"]
- default = self.create :name => "puppet", :path => Puppet[:clientbucketdir]
+ return self.create(:name => "puppet", :path => Puppet[:clientbucketdir])
end
- default
+ return nil
end
def self.instances
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 81d93a924..1c7734cc4 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -74,7 +74,8 @@ class Puppet::Util::FileType
# Pick or create a filebucket to use.
def bucket
- Puppet::Type.type(:filebucket).mkdefaultbucket.bucket
+ filebucket = Puppet::Type.type(:filebucket)
+ (filebucket["puppet"] || filebucket.mkdefaultbucket).bucket
end
def initialize(path)