summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/type/pfile.rb10
-rw-r--r--lib/puppet/type/pfile/target.rb2
-rwxr-xr-xtest/ral/types/file.rb28
3 files changed, 34 insertions, 6 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index d92a1e03d..22e7073c8 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -8,6 +8,7 @@ require 'puppet/network/server/fileserver'
module Puppet
newtype(:file) do
+ include Puppet::Util::MethodHelper
@doc = "Manages local files, including setting ownership and
permissions, creation of both files and directories, and
retrieving entire files from remote servers. As Puppet matures, it
@@ -564,7 +565,14 @@ module Puppet
# object.
def newchild(path, local, hash = {})
# make local copy of arguments
- args = @arghash.dup
+ args = symbolize_options(@arghash)
+
+ # There's probably a better way to do this, but we don't want
+ # to pass this info on.
+ if v = args[:ensure]
+ v = symbolize(v)
+ args.delete(:ensure)
+ end
if path =~ %r{^#{File::SEPARATOR}}
self.devfail(
diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb
index 3de74bb74..12e8ea732 100644
--- a/lib/puppet/type/pfile/target.rb
+++ b/lib/puppet/type/pfile/target.rb
@@ -44,7 +44,7 @@ module Puppet
end
def insync?
- if [:nochange, :notlink].include?(self.should) or @parent.should(:ensure) != :link
+ if [:nochange, :notlink].include?(self.should)
return true
else
return super
diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb
index 5b5f19299..57419164b 100755
--- a/test/ral/types/file.rb
+++ b/test/ral/types/file.rb
@@ -1452,7 +1452,7 @@ class TestFile < Test::Unit::TestCase
file = File.join(dirs["other"], "file")
sourcefile = File.join(dirs["source"], "sourcefile")
- link = File.join(dirs["target"], "link")
+ link = File.join(dirs["target"], "sourcefile")
File.open(file, "w") { |f| f.puts "other" }
File.open(sourcefile, "w") { |f| f.puts "source" }
@@ -1460,17 +1460,18 @@ class TestFile < Test::Unit::TestCase
obj = Puppet::Type.type(:file).create(
:path => dirs["target"],
- :ensure => "file",
+ :ensure => :file,
:source => dirs["source"],
:recurse => true
)
- trans = assert_events([:file_created, :file_created], obj)
+ trans = assert_apply(obj)
newfile = File.join(dirs["target"], "sourcefile")
- assert(File.exists?(newfile), "File did not get copied")
+ assert(File.directory?(dirs["target"]), "Dir did not get created")
+ assert(File.file?(newfile), "File did not get copied")
assert_equal(File.read(sourcefile), File.read(newfile),
"File did not get copied correctly.")
@@ -2072,6 +2073,25 @@ class TestFile < Test::Unit::TestCase
assert_equal(Puppet::Type.type(:filebucket)["puppet"].bucket, file.bucket,
"did not default to the 'puppet' filebucket")
end
+
+ # #515 - make sure 'ensure' other than "link" is deleted during recursion
+ def test_ensure_deleted_during_recursion
+ dir = tempfile()
+ Dir.mkdir(dir)
+ file = File.join(dir, "file")
+ File.open(file, "w") { |f| f.puts "asdfasdf" }
+
+ obj = Puppet::Type.newfile(:path => dir, :ensure => :directory,
+ :recurse => true)
+
+ children = nil
+ assert_nothing_raised do
+ children = obj.eval_generate
+ end
+ fobj = obj.class[file]
+ assert(fobj, "did not create file object")
+ assert(fobj.should(:ensure) != :directory, "ensure was passed to child")
+ end
end
# $Id$