>> Is the behavior the same if you leave off the trailing '/' from the resource title? What if you use "matches => ['[^.]*', '.[^.]*', '..?*']" (i.e. everything except . and ..)? You shouldn't have to jump through such hoops, but I think it's clear that Puppet has some deficiencies here. It the very minimum, the documentation should be improved.
>>
>> John
>>
> Good suggestion about the matches parameter.
> I will try it and let you know.
> I am fortunate in that the directory I am trying to tidy is NOT something important like "/tmp", but I share your concern.
>
> I opened a bug/issue on this before --
http://projects.puppetlabs.com/issues/15904
> I think I need to add this detail to that bug.
I tried the "matches" parameter and adding the trailing slash.
Neither preserved the top of my tree.
Using type atime does not remove directories.
Using types mtime or ctime will remove directories, but also deletes the directory named in the "path" parameter unless I use the hack of an explicit resource to protect it from being tidy-ed away.
I believe that "tidy" needs some work.
I thought of a less kludgy way to get what I want:
This is for user virtual user home folders for an FTP server. The policy is that files are removed after 5 days, so...
# /etc/puppet/modules/ftp-server/manifests/init.pp
class ftp-server ( $ftp-homedir="/tmp/default-ftp-home" ){
service { 'vsftp':
...
}
file { $ftp-homedir:
ensure => directory,
owner => root,
group => root,
mode => 775,
}
cron { 'ftp-remove-empty-dirs':
command => "/usr/bin/find ${ftp-homedir} -type d -depth -mindepth 2 -empty -exec rmdir {} \; "
user => root,
hour => 2,
minute => 10,
}
}
# /etc/puppet/modules/ftp-server/manifests/users.pp
define ftp-server::users ( $username ) {
file { "${ftp-homedir}/${username}":
ensure => directory,
owner => ftp,
group => ftp,
mode => 700;
}
tidy { "tidy-${username}":
path => "${ftp-homedir}/${username}",
age => '5d',
recurse => true,
}
}
This does what I wanted to do. The tidy resources on each virtual ftp home directory will expire the files as appropriate and the cron job will clean out the empty directories.
If anyone needs the details of the find command explained, just ask.