Hello readers, I might have the need for something like "delete all unmanaged files". Explanation: I am creating a bunch of apache config files, which contain information about the hostname and the port they''re listening on. Now if I change the host name - or the port - the last generated file keeps sitting there, and does nothing in the best case (rarely ;), and provokes errors in all others. Now because _all_ config files in those directories are generated by me & puppet I wondered if there''s a method to find out which files are _not_ genereated by puppet, and simply delete them. Any ideas, anyone? :) Thanks in advance, Axel. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/AiDCGOSj-awJ. 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.
Calvin Walton
2012-Aug-08 12:11 UTC
Re: [Puppet Users] Delete "unmanaged" files in directory
On Tue, 2012-08-07 at 22:53 -0700, Axel Bock wrote:> Hello readers, > > I might have the need for something like "delete all unmanaged files". > Explanation: I am creating a bunch of apache config files, which contain > information about the hostname and the port they''re listening on. Now if I > change the host name - or the port - the last generated file keeps sitting > there, and does nothing in the best case (rarely ;), and provokes errors in > all others. > > Now because _all_ config files in those directories are generated by me & > puppet I wondered if there''s a method to find out which files are _not_ > genereated by puppet, and simply delete them.This is pretty easy to do; the functionality is built into puppet. You just have to add a File resource for the directory, and set recurse => true, purge => true, like so: file { ''/etc/apache/sites-enabled'': ensure => ''directory'', recurse => true, purge => true, } Make sure you read the documentation for details: http://docs.puppetlabs.com/references/latest/type.html#file -- Calvin Walton <calvin.walton@kepstin.ca> -- 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.
Hi Calvin, that works great :) ! thanks! /Axel. Am Mittwoch, 8. August 2012 14:11:27 UTC+2 schrieb Calvin Walton:> > On Tue, 2012-08-07 at 22:53 -0700, Axel Bock wrote: > > Hello readers, > > > > I might have the need for something like "delete all unmanaged files". > > Explanation: I am creating a bunch of apache config files, which contain > > information about the hostname and the port they''re listening on. Now if > I > > change the host name - or the port - the last generated file keeps > sitting > > there, and does nothing in the best case (rarely ;), and provokes errors > in > > all others. > > > > Now because _all_ config files in those directories are generated by me > & > > puppet I wondered if there''s a method to find out which files are _not_ > > genereated by puppet, and simply delete them. > > This is pretty easy to do; the functionality is built into puppet. You > just have to add a File resource for the directory, and set recurse => > true, purge => true, like so: > > file { ''/etc/apache/sites-enabled'': > ensure => ''directory'', > recurse => true, > purge => true, > } > > Make sure you read the documentation for details: > http://docs.puppetlabs.com/references/latest/type.html#file > > -- > Calvin Walton <calvin...@kepstin.ca <javascript:>> > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/Z7tf1Kncc38J. 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.