I think the "force" parameter is the answer to your immediate question.

http://docs.puppetlabs.com/references/latest/type.html#file-attribute-force

That comes with the usual warning that automated recursive deletion has a 
higher than usual risk of removing something you actually needed. Since empty 
directories are often inert, possibly you might investigate if "purge" is a 
better fit for you?

http://docs.puppetlabs.com/references/latest/type.html#file-attribute-purge

On Mon, Oct 19, 2015 at 02:40:41PM +0200, Albert Shih wrote:
> Hi
> 
> Stupid question :
> 
>   I have a module who install some file/directory. I pass a parameter
>   "ensure" inside this module.
> 
>   I can do
> 
>     class my_module ($ensure ='present') {
> 
>       file { 'file0':
>         ensure => $ensure
>         etc.
> 
>       }
> 
>   so I can call my class with " ensure => 'absent' " to cleanup.
> 
> But I don't known how to do the same thing with directory. Is they are any
> easy/clean way to do that ?
> 
> I know I can do something like
> 
>   if ensure = 'present'
> 
>   { file {'directory':} }
>   else
>   { exec {'rmdir directory'}}
> 
> But seem not very clean for me.
> 
> Regards.
> 
> JAS
> 
> --
> Albert SHIH
> DIO bâtiment 15
> Observatoire de Paris
> 5 Place Jules Janssen
> 92195 Meudon Cedex
> France
> Téléphone : +33 1 45 07 76 26/+33 6 86 69 95 71
> xmpp: j...@obspm.fr
> Heure local/Local time:
> lun 19 oct 2015 14:37:03 CEST
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/20151019124041.GA5260%40pcjas.obspm.fr.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20151019134344.GA24560%40iniquitous.heresiarch.ca.
For more options, visit https://groups.google.com/d/optout.

Reply via email to