| Puppet Version: 5.5.17-1.el7 Puppet Server Version:5.3.10-1.el7 OS Name/Version: Centos 7 This is a copy of an old redmine ticket that was never resolved: https://projects.puppetlabs.com/issues/4872 To summarize, if puppet contains a declaration:
file { '/foo': |
ensure => 'link', |
target => '/bar' |
replace => false, |
}
|
...and '/foo' already exists as a dangling symlink (pointing to a file that does not exist), then puppet will change the symlink to point back to '/bar'. Desired Behavior: Puppet should respect replace => false and not replace the symlink. Actual Behavior: As described above, puppet replaces the symlink. I looked at the code and I think the current behavior is the same in master, though I don't have the means to test it myself. These parts seem relevant: lib/puppet/type/file/target.rb
def insync?(currentvalue) |
if [:nochange, :notlink].include?(self.should) or @resource.recurse? |
return true |
elsif ! @resource.replace? and Puppet::FileSystem.exist?(@resource[:path]) |
return true |
else
|
lib/puppet/file_system.rb
# Determines if a file exists by verifying that the file can be stat'd. |
# Will follow symlinks and verify that the actual target path exists. |
# |
# @return [Boolean] true if the named file exists. |
# |
# @api public |
# |
def self.exist?(path) |
@impl.exist?(assert_path(path)) |
end
|
I think that for this functionality, the file resource code should instead use a function that does not follow symlinks. Puppet is managing the file, not the target. Thanks, Corey |