Previously, pointing a setting like 'confdir' at a symlink to a directory would replace the symlink with a directory. This was because files created by settings implicitly managed links, rather than following them. This behavior is now changed so that file settings will follow links.
The behavior of these symlinks is the same as any other file resource. That is, if the target of the symlink doesn't exist, Puppet will consider this an error. Similarly, if the target of the symlink is a file, then the symlink will still be replaced with a directory, rather than replacing its target. Reviewed-By: Jacob Helwig <[email protected]> Reviewed-By: Dominic Maraglia <[email protected]> Signed-off-by: Nick Lewis <[email protected]> --- .../tests/allow_symlinks_as_config_directories.rb | 27 ++++++++++++++++++++ lib/puppet/util/settings/file_setting.rb | 1 + spec/unit/util/settings/file_setting_spec.rb | 4 +++ 3 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 acceptance/tests/allow_symlinks_as_config_directories.rb diff --git a/acceptance/tests/allow_symlinks_as_config_directories.rb b/acceptance/tests/allow_symlinks_as_config_directories.rb new file mode 100644 index 0000000..66c6ccc --- /dev/null +++ b/acceptance/tests/allow_symlinks_as_config_directories.rb @@ -0,0 +1,27 @@ +test_name "Should allow symlinks to directories as configuration directories" + +step "Create the test confdir with a link to it" +confdir = "/tmp/puppet_conf-directory-#{$$}" +conflink = "/tmp/puppet_conf-symlink-#{$$}" + +on agents, "rm -rf #{conflink} #{confdir}" + +on agents, "mkdir #{confdir}" +on agents, "ln -s #{confdir} #{conflink}" + +create_remote_file agents, "#{confdir}/puppet.conf", <<CONFFILE +[main] +certname = "awesome_certname" +CONFFILE + +manifest = 'notify{"My certname is $clientcert": }' + +step "Run Puppet and ensure it used the conf file in the confdir" +on agents, puppet_apply("--confdir #{conflink}"), :stdin => manifest do + assert_match("My certname is awesome_certname", stdout) +end + +step "Check that the symlink and confdir are unchanged" +on agents, "[ -L #{conflink} ]" +on agents, "[ -d #{confdir} ]" +on agents, "[ $(readlink #{conflink}) = #{confdir} ]" diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index edbab1d..776398e 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -101,6 +101,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting resource[:ensure] = type resource[:loglevel] = :debug + resource[:links] = :follow resource[:backup] = false resource.tag(self.section, self.name, "settings") diff --git a/spec/unit/util/settings/file_setting_spec.rb b/spec/unit/util/settings/file_setting_spec.rb index dcfb6e3..1167e97 100755 --- a/spec/unit/util/settings/file_setting_spec.rb +++ b/spec/unit/util/settings/file_setting_spec.rb @@ -249,6 +249,10 @@ describe Puppet::Util::Settings::FileSetting do it "should tag the resource with 'settings'" do @file.to_resource.should be_tagged("settings") end + + it "should set links to 'follow'" do + @file.to_resource[:links].should == :follow + end end end -- 1.7.5.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
