How to delete all files in a dir except for 2?

39 views
Skip to first unread message

Jasmine Lognnes

unread,
Mar 14, 2014, 11:55:17 AM3/14/14
to puppet...@googlegroups.com
Hello =)

Is it possible to have puppet delete all files in /commands except for c66 and c90 ?

There are ~100 files in /commands, so I would rather not do a ensure => purge for each of them =)

Are there a good way to achieve this?

Kind regards
Jasmine


Christopher Wood

unread,
Mar 14, 2014, 12:23:13 PM3/14/14
to puppet...@googlegroups.com
Try something like:

file { '/commands':
ensure => directory,
recurse => true,
purge => true,
}

That will nuke any file not managed by puppet.

Be careful of interactions with stuff like yumrepo, of course.
> --
> 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 [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/a17e999e-b9c9-4ed0-99a6-73e8fb9f2374%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/a17e999e-b9c9-4ed0-99a6-73e8fb9f2374%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

Jasmine Lognnes

unread,
Mar 14, 2014, 1:01:11 PM3/14/14
to puppet...@googlegroups.com, christop...@pobox.com
Thanks a lot =)
Reply all
Reply to author
Forward
0 new messages