summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-29 00:48:40 -0700
committerLuke Kanies <luke@madstop.com>2008-08-29 00:48:40 -0700
commit45f465bc98aa87e1066a9d748dbb6bfaaef61476 (patch)
tree79338acb1527888382256f48126a0514941164d6 /lib
parent93fc1139550bd97a11529b812e77ac0fc00c6079 (diff)
downloadpuppet-45f465bc98aa87e1066a9d748dbb6bfaaef61476.tar.gz
puppet-45f465bc98aa87e1066a9d748dbb6bfaaef61476.tar.xz
puppet-45f465bc98aa87e1066a9d748dbb6bfaaef61476.zip
Source recursion is nearly working.
It works, but you have to run it multiple times, and there are still a couple of strangenesses with the parameter values, such as the mode not getting set on the first run. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type/file.rb29
-rwxr-xr-xlib/puppet/type/file/source.rb11
2 files changed, 28 insertions, 12 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index a59192af3..ce1df1c35 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -564,8 +564,9 @@ module Puppet
# the right-side hash wins in the merge.
options = to_hash.merge(:path => full_path, :implicit => true)
- options.delete(:parent) if options.include?(:parent)
- options.delete(:recurse) if options.include?(:recurse)
+ [:parent, :recurse, :target].each do |param|
+ options.delete(param) if options.include?(param)
+ end
return self.class.create(options)
end
@@ -632,6 +633,11 @@ module Puppet
# Recurse the target of the link.
def recurse_link(children)
perform_recursion(self[:target]).each do |meta|
+ if meta.relative_path == "."
+ self[:ensure] = :directory
+ next
+ end
+
children[meta.relative_path] ||= newchild(meta.relative_path)
if meta.ftype == "directory"
children[meta.relative_path][:ensure] = :directory
@@ -645,7 +651,9 @@ module Puppet
# Recurse the file itself, returning a Metadata instance for every found file.
def recurse_local
- perform_recursion(self[:path]).inject({}) do |hash, meta|
+ result = perform_recursion(self[:path])
+ return {} unless result
+ result.inject({}) do |hash, meta|
next hash if meta.relative_path == "."
hash[meta.relative_path] = newchild(meta.relative_path)
@@ -675,8 +683,14 @@ module Puppet
end
total.each do |meta|
+ if meta.relative_path == "."
+ property(:source).metadata = meta
+ next
+ end
children[meta.relative_path] ||= newchild(meta.relative_path)
children[meta.relative_path][:source] = meta.source
+ children[meta.relative_path][:checksum] = :md5 if meta.ftype == "file"
+
children[meta.relative_path].property(:source).metadata = meta
end
@@ -759,21 +773,22 @@ module Puppet
# a wrapper method to make sure the file exists before doing anything
def retrieve
unless stat = self.stat(true)
- # If the file doesn't exist but we have a source, then call
- # retrieve on that property
propertyvalues = properties().inject({}) { |hash, property|
hash[property] = :absent
hash
}
+ # If the file doesn't exist but we have a source, then call
+ # retrieve on the source property so it will set the 'should'
+ # values all around.
if @parameters.include?(:source)
- propertyvalues[:source] = @parameters[:source].retrieve
+ @parameters[:source].copy_source_values
end
return propertyvalues
end
- return currentpropvalues()
+ currentpropvalues()
end
# This recurses against the remote source and makes sure the local
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 03cc311b4..e43706051 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -122,13 +122,14 @@ module Puppet
# Take each of the stats and set them as states on the local file
# if a value has not already been provided.
- [:owner, :mode, :group].each do |param|
- @resource[param] ||= metadata.send(param)
+ [:owner, :mode, :group, :checksum].each do |param|
+ next if param == :owner and Puppet::Util::SUIDManager.uid != 0
+ unless value = @resource[param] and value != :absent
+ @resource[param] = metadata.send(param)
+ end
end
- unless @resource.deleting?
- @resource[:ensure] = metadata.ftype
- end
+ @resource[:ensure] = metadata.ftype
if metadata.ftype == "link"
@resource[:target] = metadata.destination