I'm doing this:
class puppet::clean_reports {
cron { "puppet clean reports":
command => 'cd /var/lib/puppet/reports && find . -type f
-name \*.yaml -mtime +7 -print0 | xargs -0 -n50 /bin/rm -f',
user => root,
hour => 21,
minute => 22,
weekday => 0,
}
}
If there's a better way I'd love to hear it.
--
vagn
Thinking about this some more, if you need the reports for dashboard to
work,
then any cleanup script should leave the latest report from any server,
so that, even if the server has not checked in for a while it won't
disappear.
Thanks for the question. Clearly I need to revisit this.
--
vagn
So, here is a script that ought to do the job. Not heavily tested yet.
Please let me know if you have problems with it. --vagn
#! /bin/sh
# puppet-reports-stalker
# vagn scott, 21-jul-2011
days="+7" # more than 7 days old
for d in `find /var/lib/puppet/reports -mindepth 1 -maxdepth 1 -type d`
do
find $d -type f -name \*.yaml -mtime $days |
sort -r |
tail -n +2 |
xargs -n50 /bin/rm -f
done
exit 0
And the updated class.
class puppet::clean_reports {
file { '/usr/local/bin/puppet-reports-stalker':
source => 'puppet:///modules/puppet/puppet-reports-stalker',
before => Cron[ 'puppet clean reports' ],
mode => 755,
owner => root,
group => root,
}
cron { 'puppet clean reports':
command => '/usr/local/bin/puppet-reports-stalker',
Great solution. Simple, effective. Thanks.
--
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...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
case
$hostname {
/^puppet$/:
{
tidy
{ 'puppet::reports':
path
=> '/var/lib/puppet/reports',
matches
=> '*',
age
=> '14d',
backup
=> false,
recurse
=> true,
rmdirs
=> true,
type
=> 'ctime',
}
#
notify { "debug: tidy command should run now": }
}
}
Ciao,
Andrew.
--
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...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/q8vWDr3bn4Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
--
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...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.
Don't forget to run the command suggested in http://docs.puppetlabs.com/dashboard/manual/1.2/maintaining.html
Josh
Hi, I'm revisiting this topic.
Wasn't garbage collector supposed to clean up the old reports and leave the last "report-ttl" on disk? Or this is valid only for the reports stored in the PuppetDB's database?
puppet config print --section master reports