diff --git a/manifests/init.pp b/manifests/init.pp index b665d65..76f3a15 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -26,6 +26,7 @@ class nodepool ( $statsd_host = undef, $vhost_name = $::fqdn, $image_log_document_root = '/var/log/nodepool/image', + $image_log_periodic_cleanup = false, $enable_image_log_via_http = false, $environment = {}, # enable sudo for nodepool user. Useful for using dib with nodepool @@ -303,6 +304,18 @@ class nodepool ( } } + # run a cleanup on the image log directory to cleanup logs for + # images that are no longer being built + if $image_log_periodic_cleanup == true { + cron { 'image_log_cleanup': + user => 'nodepool', + hour => '1', + minute => '0', + command => "find ${image_log_document_root} -name '*.log' -mtime +7 -execdir rm {} \\;", + environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin', + } + } + if $sudo == true { $sudo_file_ensure = present }