Rich Rauenzahn
2011-Feb-15 01:17 UTC
[Puppet Users] force directory to symlink, but only if empty
I was surprised to find that file { $foo: ensure => symlink, target => ''/tmp/foo'', } doesn''t replace $foo if $foo is an empty directory. Is there a particular combination of options to the file resource that would replace the directory with the symlink if empty, but wouldn''t filebucket the contents and the directory if it wasn''t empty? recurse=false doesn''t do it... Rich -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Feb-15 01:20 UTC
Re: [Puppet Users] force directory to symlink, but only if empty
On Mon, Feb 14, 2011 at 5:17 PM, Rich Rauenzahn <rrauenza@gmail.com> wrote:> I was surprised to find that > > file { $foo: > ensure => symlink, > target => ''/tmp/foo'', > } > > doesn''t replace $foo if $foo is an empty directory. > > Is there a particular combination of options to the file resource that > would replace the directory with the symlink if empty, but wouldn''t > filebucket the contents and the directory if it wasn''t empty?See http://docs.puppetlabs.com/references/latest/type.html#file force => true Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Rich Rauenzahn
2011-Feb-15 02:08 UTC
Re: [Puppet Users] force directory to symlink, but only if empty
On Mon, Feb 14, 2011 at 5:20 PM, Nan Liu <nan@puppetlabs.com> wrote:> On Mon, Feb 14, 2011 at 5:17 PM, Rich Rauenzahn <rrauenza@gmail.com> wrote: >> I was surprised to find that >> >> file { $foo: >> ensure => symlink, >> target => ''/tmp/foo'', >> } >> >> doesn''t replace $foo if $foo is an empty directory. >> >> Is there a particular combination of options to the file resource that >> would replace the directory with the symlink if empty, but wouldn''t >> filebucket the contents and the directory if it wasn''t empty? > > See http://docs.puppetlabs.com/references/latest/type.html#file > force => trueThat is what I''m doing. But force also empties the directory if it has contents. I don''t want that. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Feb-15 06:07 UTC
Re: [Puppet Users] force directory to symlink, but only if empty
On Mon, Feb 14, 2011 at 6:08 PM, Rich Rauenzahn <rrauenza@gmail.com> wrote:> On Mon, Feb 14, 2011 at 5:20 PM, Nan Liu <nan@puppetlabs.com> wrote: >> On Mon, Feb 14, 2011 at 5:17 PM, Rich Rauenzahn <rrauenza@gmail.com> wrote: >>> I was surprised to find that >>> >>> file { $foo: >>> ensure => symlink, >>> target => ''/tmp/foo'', >>> } >>> >>> doesn''t replace $foo if $foo is an empty directory. >>> >>> Is there a particular combination of options to the file resource that >>> would replace the directory with the symlink if empty, but wouldn''t >>> filebucket the contents and the directory if it wasn''t empty? >> >> See http://docs.puppetlabs.com/references/latest/type.html#file >> force => true > > That is what I''m doing. But force also empties the directory if it > has contents. I don''t want that.Sorry missed the details, you can impose this behavior using an exec and make the file resource depend on the exec. The exec will fail for a non empty directory: exec { "remove_empty_dir": command => "rmdir /tmp/foo", path => "/bin:/usr/bin", onlyif => "[ -d /tmp/foo ]", } Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.