From 0f4718f062f7419092f69dcdd951339a466a79b8 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 7 Jul 2011 00:52:08 +0200 Subject: migrate cleanup_reports to parametrized classes as this makes it much more configurable --- manifests/puppetmaster.pp | 10 ++-------- manifests/puppetmaster/cleanup_reports.pp | 19 ++++++++++++++----- manifests/puppetmaster/cleanup_reports/disable.pp | 6 ------ 3 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 manifests/puppetmaster/cleanup_reports/disable.pp (limited to 'manifests') diff --git a/manifests/puppetmaster.pp b/manifests/puppetmaster.pp index 3e8711c..55e1dab 100644 --- a/manifests/puppetmaster.pp +++ b/manifests/puppetmaster.pp @@ -29,14 +29,8 @@ class puppet::puppetmaster inherits puppet { include puppet::puppetmaster::cluster } - case $puppetmaster_cleanup_reports { - '': { $puppetmaster_cleanup_reports = '30' } - } - - if $puppetmaster_cleanup_reports { - include puppet::puppetmaster::cleanup_reports - } else { - include puppet::puppetmaster::cleanup_reports::disable + class{'puppet::puppetmaster::cleanup_reports': + cleanup_older_than => '30', } if $use_shorewall { diff --git a/manifests/puppetmaster/cleanup_reports.pp b/manifests/puppetmaster/cleanup_reports.pp index 664bd81..d25e8ac 100644 --- a/manifests/puppetmaster/cleanup_reports.pp +++ b/manifests/puppetmaster/cleanup_reports.pp @@ -1,8 +1,17 @@ -class puppet::puppetmaster::cleanup_reports { +class puppet::puppetmaster::cleanup_reports( + $cleanup_older_than = 'absent', + $reports_dir = '/var/lib/puppet/reports/' +){ + file { '/etc/cron.daily/puppet_reports_cleanup.sh': } - # clean up reports older than $puppetmaster_cleanup_reports days - file { '/etc/cron.daily/puppet_reports_cleanup.sh': - content => "#!/bin/bash\nfind /var/lib/puppet/reports/ -maxdepth 2 -type f -ctime +${puppetmaster_cleanup_reports} -exec rm {} \\;\n", - owner => root, group => 0, mode => 0700; + if $cleanup_older_than != 'absent' { + File['/etc/cron.daily/puppet_reports_cleanup.sh']{ + content => "#!/bin/bash\nfind ${puppet::puppetmaster::cleanup_reports::reports_dir} -maxdepth 2 -type f -ctime +${puppet::puppetmaster::cleanup_reports::cleanup_olderthan} -exec rm {} \\;\n", + owner => root, group => 0, mode => 0700, + } + } else { + File['/etc/cron.daily/puppet_reports_cleanup.sh']{ + ensure => absent, + } } } diff --git a/manifests/puppetmaster/cleanup_reports/disable.pp b/manifests/puppetmaster/cleanup_reports/disable.pp deleted file mode 100644 index 8636223..0000000 --- a/manifests/puppetmaster/cleanup_reports/disable.pp +++ /dev/null @@ -1,6 +0,0 @@ -class puppet::puppetmaster::cleanup_reports::disable inherits puppet::puppetmaster::cleanup_reports { - - File['/etc/cron.daily/puppet_reports_cleanup.sh']{ - ensure => absent, - } -} -- cgit v1.2.3