summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/metatype/container.rb1
-rw-r--r--lib/puppet/metatype/instances.rb41
-rw-r--r--lib/puppet/metatype/metaparams.rb4
-rw-r--r--lib/puppet/metatype/relationships.rb7
-rw-r--r--lib/puppet/metatype/schedules.rb6
-rw-r--r--lib/puppet/network/client/master.rb1
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb7
-rwxr-xr-xlib/puppet/network/handler/resource.rb14
-rw-r--r--lib/puppet/network/server.rb2
-rw-r--r--lib/puppet/node.rb2
-rw-r--r--lib/puppet/node/catalog.rb6
-rw-r--r--lib/puppet/resource_reference.rb11
-rw-r--r--lib/puppet/transaction.rb4
-rw-r--r--lib/puppet/type.rb6
-rw-r--r--lib/puppet/type/component.rb4
-rw-r--r--lib/puppet/type/file.rb27
-rwxr-xr-xlib/puppet/type/filebucket.rb14
-rwxr-xr-xlib/puppet/type/schedule.rb16
-rwxr-xr-xlib/puppet/type/user.rb14
-rw-r--r--lib/puppet/type/yumrepo.rb5
-rwxr-xr-xlib/puppet/util/filetype.rb9
-rwxr-xr-xlib/puppet/util/posix.rb39
-rw-r--r--lib/puppet/util/settings.rb92
23 files changed, 73 insertions, 259 deletions
diff --git a/lib/puppet/metatype/container.rb b/lib/puppet/metatype/container.rb
index 2bbe3f546..dbc8a3dee 100644
--- a/lib/puppet/metatype/container.rb
+++ b/lib/puppet/metatype/container.rb
@@ -36,7 +36,6 @@ class Puppet::Type
obj.remove
end
@parameters.clear
- self.class.delete(self)
@parent = nil
diff --git a/lib/puppet/metatype/instances.rb b/lib/puppet/metatype/instances.rb
index 3f44413f8..34d542c5d 100644
--- a/lib/puppet/metatype/instances.rb
+++ b/lib/puppet/metatype/instances.rb
@@ -8,11 +8,13 @@ class Puppet::Type
# retrieve a named instance of the current type
def self.[](name)
+ raise "Global resource access is deprecated"
@objects[name] || @aliases[name]
end
# add an instance by name to the class list of instances
def self.[]=(name,object)
+ raise "Global resource storage is deprecated"
newobj = nil
if object.is_a?(Puppet::Type)
newobj = object
@@ -44,6 +46,7 @@ class Puppet::Type
# Create an alias. We keep these in a separate hash so that we don't encounter
# the objects multiple times when iterating over them.
def self.alias(name, obj)
+ raise "Global resource aliasing is deprecated"
if @objects.include?(name)
unless @objects[name] == obj
raise Puppet::Error.new(
@@ -67,6 +70,7 @@ class Puppet::Type
# remove all of the instances of a single type
def self.clear
+ raise "Global resource removal is deprecated"
if defined? @objects
@objects.each do |name, obj|
obj.remove(true)
@@ -126,24 +130,6 @@ class Puppet::Type
# XXX This will have to change when transobjects change to using titles
title = hash.name
- # if the object already exists
- if self.isomorphic? and retobj = self[title]
- # if only one of our objects is implicit, then it's easy to see
- # who wins -- the non-implicit one.
- if retobj.implicit? and ! implicit
- Puppet.notice "Removing implicit %s" % retobj.title
- # Remove all of the objects, but do not remove their subscriptions.
- retobj.remove(false)
-
- # now pass through and create the new object
- elsif implicit
- Puppet.debug "Ignoring implicit %s[%s]" % [self.name, title]
- return nil
- else
- raise Puppet::Error, "%s is already being managed" % retobj.ref
- end
- end
-
# create it anew
# if there's a failure, destroy the object if it got that far, but raise
# the error.
@@ -153,8 +139,6 @@ class Puppet::Type
Puppet.err "Could not create %s: %s" % [title, detail.to_s]
if obj
obj.remove(true)
- elsif obj = self[title]
- obj.remove(true)
end
raise
end
@@ -163,14 +147,12 @@ class Puppet::Type
obj.implicit = true
end
- # Store the object by title
- self[obj.title] = obj
-
return obj
end
# remove a specified object
def self.delete(resource)
+ raise "Global resource removal is deprecated"
return unless defined? @objects
if @objects.include?(resource.title)
@objects.delete(resource.title)
@@ -191,6 +173,7 @@ class Puppet::Type
# iterate across each of the type's instances
def self.each
+ raise "Global resource iteration is deprecated"
return unless defined? @objects
@objects.each { |name,instance|
yield instance
@@ -199,6 +182,7 @@ class Puppet::Type
# does the type have an object with the given name?
def self.has_key?(name)
+ raise "Global resource access is deprecated"
return @objects.has_key?(name)
end
@@ -258,10 +242,6 @@ class Puppet::Type
provider_instances = {}
providers_by_source.collect do |provider|
provider.instances.collect do |instance|
- # First try to get the resource if it already exists
- # Skip instances that map to a managed resource with a different provider
- next if resource = self[instance.name] and resource.provider.class != instance.class
-
# We always want to use the "first" provider instance we find, unless the resource
# is already managed and has a different provider set
if other = provider_instances[instance.name]
@@ -271,12 +251,7 @@ class Puppet::Type
end
provider_instances[instance.name] = instance
- if resource
- resource.provider = instance
- resource
- else
- create(:name => instance.name, :provider => instance, :check => :all)
- end
+ create(:name => instance.name, :provider => instance, :check => :all)
end
end.flatten.compact
end
diff --git a/lib/puppet/metatype/metaparams.rb b/lib/puppet/metatype/metaparams.rb
index edd594114..bf64d3a93 100644
--- a/lib/puppet/metatype/metaparams.rb
+++ b/lib/puppet/metatype/metaparams.rb
@@ -207,9 +207,6 @@ class Puppet::Type
next
end
- # LAK:FIXME Old-school, add the alias to the class.
- @resource.class.alias(other, @resource)
-
# Newschool, add it to the catalog.
@resource.catalog.alias(@resource, other)
end
@@ -277,6 +274,7 @@ class Puppet::Type
# to an object...
tname, name = value
reference = Puppet::ResourceReference.new(tname, name)
+ reference.catalog = resource.catalog
# Either of the two retrieval attempts could have returned
# nil.
diff --git a/lib/puppet/metatype/relationships.rb b/lib/puppet/metatype/relationships.rb
index 4fb78ae56..0070c6efb 100644
--- a/lib/puppet/metatype/relationships.rb
+++ b/lib/puppet/metatype/relationships.rb
@@ -17,7 +17,10 @@ class Puppet::Type
# Figure out of there are any objects we can automatically add as
# dependencies.
- def autorequire
+ def autorequire(rel_catalog = nil)
+ rel_catalog ||= catalog
+ raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
+
reqs = []
self.class.eachautorequire { |type, block|
# Ignore any types we can't find, although that would be a bit odd.
@@ -35,7 +38,7 @@ class Puppet::Type
# Support them passing objects directly, to save some effort.
unless dep.is_a? Puppet::Type
# Skip autorequires that we aren't managing
- unless dep = typeobj[dep]
+ unless dep = rel_catalog.resource(type, dep)
next
end
end
diff --git a/lib/puppet/metatype/schedules.rb b/lib/puppet/metatype/schedules.rb
index 96ebce0ab..b4782f852 100644
--- a/lib/puppet/metatype/schedules.rb
+++ b/lib/puppet/metatype/schedules.rb
@@ -3,9 +3,13 @@ class Puppet::Type
# the instantiation phase, so that the schedule can be anywhere in the
# file.
def schedule
+ unless catalog
+ warning "Cannot schedule without a schedule-containing catalog"
+ return nil
+ end
unless defined? @schedule
if name = self[:schedule]
- if sched = Puppet.type(:schedule)[name]
+ if sched = catalog.resource(:schedule, name)
@schedule = sched
else
self.fail "Could not find schedule %s" % name
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 22bb3fa4e..a2b6499bb 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -75,7 +75,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
def clear
@catalog.clear(true) if @catalog
- Puppet::Type.allclear
@catalog = nil
end
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 3e62cdbd9..183979429 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -496,12 +496,14 @@ class Puppet::Network::Handler
@path = nil
end
+ @files = {}
+
super()
end
def fileobj(path, links, client)
obj = nil
- if obj = Puppet.type(:file)[file_path(path, client)]
+ if obj = @files[file_path(path, client)]
# This can only happen in local fileserving, but it's an
# important one. It'd be nice if we didn't just set
# the check params every time, but I'm not sure it's worth
@@ -512,6 +514,7 @@ class Puppet::Network::Handler
:name => file_path(path, client),
:check => CHECKPARAMS
)
+ @files[file_path(path, client)] = obj
end
if links == :manage
@@ -528,7 +531,7 @@ class Puppet::Network::Handler
# Read the contents of the file at the relative path given.
def read_file(relpath, client)
- File.read(file_path(relpath, client))
+ File.read(file_path(relpath, client))
end
# Cache this manufactured map, since if it's used it's likely
diff --git a/lib/puppet/network/handler/resource.rb b/lib/puppet/network/handler/resource.rb
index f2a339751..7ec27b4dc 100755
--- a/lib/puppet/network/handler/resource.rb
+++ b/lib/puppet/network/handler/resource.rb
@@ -68,15 +68,11 @@ class Puppet::Network::Handler
retrieve ||= :all
ignore ||= []
- if obj = typeklass[name]
- obj[:check] = retrieve
- else
- begin
- obj = typeklass.create(:name => name, :check => retrieve)
- rescue Puppet::Error => detail
- raise Puppet::Error, "%s[%s] could not be created: %s" %
- [type, name, detail]
- end
+ begin
+ obj = typeklass.create(:name => name, :check => retrieve)
+ rescue Puppet::Error => detail
+ raise Puppet::Error, "%s[%s] could not be created: %s" %
+ [type, name, detail]
end
unless obj
diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb
index 50e3bd686..f2c8dc18c 100644
--- a/lib/puppet/network/server.rb
+++ b/lib/puppet/network/server.rb
@@ -1,3 +1,5 @@
+require 'puppet/network/http'
+
class Puppet::Network::Server
attr_reader :server_type, :protocols, :address, :port
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index c0628ecdc..252ab961e 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -161,5 +161,7 @@ class Puppet::Node
params.each do |name, value|
@parameters[name] = value unless @parameters.include?(name)
end
+
+ @parameters["environment"] ||= self.environment if self.environment
end
end
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index ecda472be..c5e32a032 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -61,7 +61,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
def add_resource(*resources)
resources.each do |resource|
unless resource.respond_to?(:ref)
- raise ArgumentError, "Can only add objects that respond to :ref"
+ raise ArgumentError, "Can only add objects that respond to :ref, not instances of %s" % resource.class
end
fail_unless_unique(resource)
@@ -309,7 +309,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
# And filebuckets
if bucket = Puppet::Type.type(:filebucket).mkdefaultbucket
- add_resource(bucket)
+ add_resource(bucket) unless resource(bucket.ref)
end
end
@@ -337,7 +337,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
# Lastly, add in any autorequires
@relationship_graph.vertices.each do |vertex|
- vertex.autorequire.each do |edge|
+ vertex.autorequire(self).each do |edge|
unless @relationship_graph.edge?(edge.source, edge.target) # don't let automatic relationships conflict with manual ones.
unless @relationship_graph.edge?(edge.target, edge.source)
vertex.debug "Autorequiring %s" % [edge.source]
diff --git a/lib/puppet/resource_reference.rb b/lib/puppet/resource_reference.rb
index 44b518816..12b9f54a9 100644
--- a/lib/puppet/resource_reference.rb
+++ b/lib/puppet/resource_reference.rb
@@ -22,15 +22,8 @@ class Puppet::ResourceReference
# Find our resource.
def resolve
- if catalog
- return catalog.resource(to_s)
- end
- # If it's builtin, then just ask for it directly from the type.
- if t = builtin_type
- t[@title]
- else # Else, look for a component with the full reference as the name.
- Puppet::Type::Component[to_s]
- end
+ return catalog.resource(to_s) if catalog
+ return nil
end
# If the title has square brackets, treat it like a reference and
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 14b2037f4..d4bc42100 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -153,7 +153,7 @@ class Transaction
# contained resources might never get cleaned up.
def cleanup
if defined? @generated
- relationship_graph.remove_resource(*@generated)
+ catalog.remove_resource(*@generated)
end
end
@@ -503,7 +503,7 @@ class Transaction
# Now add any dynamically generated resources
generate()
-
+
# This will throw an error if there are cycles in the graph.
@sorted_resources = relationship_graph.topsort
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index f8949ec90..7deb25fff 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -229,14 +229,14 @@ class Type
end
# If the name and title differ, set up an alias
- if self.name != self.title
- if obj = self.class[self.name]
+ if self.name != self.title and self.catalog
+ if obj = catalog.resource(self.class.name, self.name)
if self.class.isomorphic?
raise Puppet::Error, "%s already exists with name %s" %
[obj.title, self.name]
end
else
- self.class.alias(self.name, self)
+ catalog.alias(self, self.name)
end
end
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb
index 356205089..1d1bc9ee8 100644
--- a/lib/puppet/type/component.rb
+++ b/lib/puppet/type/component.rb
@@ -88,8 +88,8 @@ Puppet::Type.newtype(:component) do
@reference = Puppet::ResourceReference.new(:component, @title)
- unless self.class[@reference.to_s]
- self.class.alias(@reference.to_s, self)
+ if catalog and ! catalog.resource[@reference.to_s]
+ catalog.alias(self, @reference.to_s)
end
end
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 3518e8bb3..7b9233736 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -78,9 +78,8 @@ module Puppet
munge do |value|
# I don't really know how this is happening.
- if value.is_a?(Array)
- value = value.shift
- end
+ value = value.shift if value.is_a?(Array)
+
case value
when false, "false", :false:
false
@@ -92,7 +91,7 @@ module Puppet
# We can't depend on looking this up right now,
# we have to do it after all of the objects
# have been instantiated.
- if bucketobj = Puppet::Type.type(:filebucket)[value]
+ if resource.catalog and bucketobj = resource.catalog.resource(:filebucket, value)
@resource.bucket = bucketobj.bucket
bucketobj.title
else
@@ -304,30 +303,23 @@ module Puppet
# We have to do some extra finishing, to retrieve our bucket if
# there is one.
def finish
- # Let's cache these values, since there should really only be
- # a couple of these buckets
- @@filebuckets ||= {}
-
# Look up our bucket, if there is one
if bucket = self.bucket
case bucket
when String:
- if obj = @@filebuckets[bucket]
- # This sets the @value on :backup, too
- self.bucket = obj
+ if catalog and obj = catalog.resource(:filebucket, bucket)
+ self.bucket = obj.bucket
elsif bucket == "puppet"
obj = Puppet::Network::Client.client(:Dipper).new(
:Path => Puppet[:clientbucketdir]
)
self.bucket = obj
- @@filebuckets[bucket] = obj
- elsif obj = Puppet::Type.type(:filebucket).bucket(bucket)
- @@filebuckets[bucket] = obj
- self.bucket = obj
else
- self.fail "Could not find filebucket %s" % bucket
+ self.fail "Could not find filebucket '%s'" % bucket
end
when Puppet::Network::Client.client(:Dipper): # things are hunky-dorey
+ when Puppet::Type::Filebucket # things are hunky-dorey
+ self.bucket = bucket.bucket
else
self.fail "Invalid bucket type %s" % bucket.class
end
@@ -432,8 +424,7 @@ module Puppet
end
when "link": return true
else
- self.notice "Cannot backup files of type %s" %
- File.stat(file).ftype
+ self.notice "Cannot backup files of type %s" % File.stat(file).ftype
return false
end
end
diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb
index b268610e9..872bded4e 100755
--- a/lib/puppet/type/filebucket.rb
+++ b/lib/puppet/type/filebucket.rb
@@ -54,21 +54,9 @@ module Puppet
defaultto { Puppet[:clientbucketdir] }
end
- # get the actual filebucket object
- def self.bucket(name)
- if object = self[name]
- return object.bucket
- else
- return nil
- end
- end
-
# Create a default filebucket.
def self.mkdefaultbucket
- unless default = self["puppet"]
- return self.create(:name => "puppet", :path => Puppet[:clientbucketdir])
- end
- return nil
+ 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 b8479e01d..ecbf7d49a 100755
--- a/lib/puppet/type/schedule.rb
+++ b/lib/puppet/type/schedule.rb
@@ -241,7 +241,9 @@ module Puppet
:daily => :day,
:monthly => :month,
:weekly => proc do |prev, now|
- prev.strftime("%U") != now.strftime("%U")
+ # Run the resource if the previous day was after this weekday (e.g., prev is wed, current is tue)
+ # or if it's been more than a week since we ran
+ prev.wday > now.wday or (now - prev) > (24 * 3600 * 7)
end
}
@@ -314,8 +316,6 @@ module Puppet
end
def self.mkdefaultschedules
- return [] if self["puppet"]
-
result = []
Puppet.debug "Creating default schedules"
result << self.create(
@@ -326,12 +326,10 @@ module Puppet
# And then one for every period
@parameters.find { |p| p.name == :period }.values.each { |value|
- unless self[value.to_s]
- result << self.create(
- :name => value.to_s,
- :period => value
- )
- end
+ result << self.create(
+ :name => value.to_s,
+ :period => value
+ )
}
result
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 71507d172..0b668395d 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -302,19 +302,7 @@ module Puppet
group
end
}
- groups.each { |group|
- case group
- when Integer:
- if obj = Puppet.type(:group).find { |gobj|
- gobj.should(:gid) == group
- }
- autos << obj
-
- end
- else
- autos << group
- end
- }
+ autos = groups.reject { |g| g.is_a?(Integer) }
end
if obj = @parameters[:groups] and groups = obj.should
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index acb3b9b83..8800dd71d 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -67,8 +67,9 @@ module Puppet
class << self
attr_accessor :filetype
# The writer is only used for testing, there should be no need
- # to change yumconf in any other context
+ # to change yumconf or inifile in any other context
attr_accessor :yumconf
+ attr_writer :inifile
end
self.filetype = Puppet::Util::FileType.filetype(:flat)
@@ -181,11 +182,11 @@ module Puppet
inifile.store
end
+ # This is only used during testing.
def self.clear
@inifile = nil
@yumconf = "/etc/yum.conf"
@defaultrepodir = nil
- super
end
# Return the Puppet::Util::IniConfig::Section for this yumrepo resource
diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb
index 8dcb67286..ae078fff4 100755
--- a/lib/puppet/util/filetype.rb
+++ b/lib/puppet/util/filetype.rb
@@ -74,8 +74,10 @@ class Puppet::Util::FileType
# Pick or create a filebucket to use.
def bucket
- filebucket = Puppet::Type.type(:filebucket)
- (filebucket["puppet"] || filebucket.mkdefaultbucket).bucket
+ unless defined?(@bucket)
+ @bucket = Puppet::Type.type(:filebucket).mkdefaultbucket.bucket
+ end
+ @bucket
end
def initialize(path)
@@ -104,6 +106,9 @@ class Puppet::Util::FileType
# Overwrite the file.
def write(text)
backup()
+
+ raise("Cannot create file %s in absent directory" % @path) unless FileTest.exist?(File.dirname(@path))
+
require "tempfile"
tf = Tempfile.new("puppet")
tf.print text; tf.flush
diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb
index cc0340ef7..8228734ef 100755
--- a/lib/puppet/util/posix.rb
+++ b/lib/puppet/util/posix.rb
@@ -63,45 +63,6 @@ module Puppet::Util::POSIX
return nil
end
- # Look in memory for an already-managed type and use its info if available.
- # Currently unused.
- def get_provider_value(type, field, id)
- unless typeklass = Puppet::Type.type(type)
- raise ArgumentError, "Invalid type %s" % type
- end
-
- id = id.to_s
-
- chkfield = idfield(type)
- obj = typeklass.find { |obj|
- if id =~ /^\d+$/
- obj.should(chkfield).to_s == id ||
- obj.provider.send(chkfield) == id
- else
- obj[:name] == id
- end
- }
-
- return nil unless obj
-
- if obj.provider
- begin
- val = obj.provider.send(field)
- if val == :absent
- return nil
- else
- return val
- end
- rescue => detail
- if Puppet[:trace]
- puts detail.backtrace
- Puppet.err detail
- return nil
- end
- end
- end
- end
-
# Determine what the field name is for users and groups.
def idfield(space)
case Puppet::Util.symbolize(space)
diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index d27406d6d..24a71516a 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -65,7 +65,6 @@ class Puppet::Util::Settings
config = trans.to_catalog
config.store_state = false
config.apply
- config.clear
rescue => detail
if Puppet[:trace]
puts detail.backtrace
@@ -312,94 +311,6 @@ class Puppet::Util::Settings
end
end
- # Parse the configuration file. As of May 2007, this is a backward-compatibility method and
- # will be deprecated soon.
- def old_parse(file)
- text = nil
-
- if file.is_a? Puppet::Util::LoadedFile
- @file = file
- else
- @file = Puppet::Util::LoadedFile.new(file)
- end
-
- # Don't create a timer for the old style parsing.
- # settimer()
-
- begin
- text = File.read(@file.file)
- rescue Errno::ENOENT
- raise Puppet::Error, "No such file %s" % file
- rescue Errno::EACCES
- raise Puppet::Error, "Permission denied to file %s" % file
- end
-
- @values = Hash.new { |names, name|
- names[name] = {}
- }
-
- # Get rid of the values set by the file, keeping cli values.
- self.clear(true)
-
- section = "puppet"
- metas = %w{owner group mode}
- values = Hash.new { |hash, key| hash[key] = {} }
- text.split(/\n/).each { |line|
- case line
- when /^\[(\w+)\]$/: section = $1 # Section names
- when /^\s*#/: next # Skip comments
- when /^\s*$/: next # Skip blanks
- when /^\s*(\w+)\s*=\s*(.+)$/: # settings
- var = $1.intern
- if var == :mode
- value = $2
- else
- value = munge_value($2)
- end
-
- # Only warn if we don't know what this config var is. This
- # prevents exceptions later on.
- unless @config.include?(var) or metas.include?(var.to_s)
- Puppet.warning "Discarded unknown configuration parameter %s" % var.inspect
- next # Skip this line.
- end
-
- # Mmm, "special" attributes
- if metas.include?(var.to_s)
- unless values.include?(section)
- values[section] = {}
- end
- values[section][var.to_s] = value
-
- # If the parameter is valid, then set it.
- if section == Puppet[:name] and @config.include?(var)
- #@config[var].value = value
- @values[:main][var] = value
- end
- next
- end
-
- # Don't override set parameters, since the file is parsed
- # after cli arguments are handled.
- unless @config.include?(var) and @config[var].setbycli
- Puppet.debug "%s: Setting %s to '%s'" % [section, var, value]
- @values[:main][var] = value
- end
- @config[var].section = symbolize(section)
-
- metas.each { |meta|
- if values[section][meta]
- if @config[var].respond_to?(meta + "=")
- @config[var].send(meta + "=", values[section][meta])
- end
- end
- }
- else
- raise Puppet::Error, "Could not match line %s" % line
- end
- }
- end
-
# Create a new element. The value is passed in because it's used to determine
# what kind of element we're creating, but the value itself might be either
# a default or a value, so we can't actually assign it.
@@ -677,8 +588,6 @@ Generated on #{Time.now}.
raise "Could not configure for running; got %s failure(s)" % failures
end
end
- ensure
- catalog.clear
end
sections.each { |s| @used << s }
@@ -1163,7 +1072,6 @@ Generated on #{Time.now}.
return nil unless path.is_a?(String)
return nil if path =~ /^\/dev/
- return nil if Puppet::Type.type(:file)[path] # skip files that are in our global resource list.
objects = []