puppet: Merged puppet-report-cleanup from parameterize branch.
This commit is contained in:
parent
766f7d06a5
commit
3cf4363186
2 changed files with 35 additions and 15 deletions
|
@ -249,12 +249,10 @@ class puppet::server {
|
|||
# Database password.
|
||||
#
|
||||
# $puppet_report_maxage:
|
||||
# Maximum age (in hours) to keep reports. Defaults to 720 hours (30 days).
|
||||
# Maximum age (in days) to keep reports. Defaults to 30 days.
|
||||
#
|
||||
class puppet::server::common inherits puppet::client {
|
||||
|
||||
include tmpwatch
|
||||
|
||||
if $::operatingsystem in ["CentOS","RedHat"] and $::operatingsystemrelease =~ /^[1-5]\..*/ {
|
||||
$seltype = "var_lib_t"
|
||||
} else {
|
||||
|
@ -477,20 +475,37 @@ class puppet::server::common inherits puppet::client {
|
|||
require => Package["puppetmaster"],
|
||||
}
|
||||
|
||||
if !$puppet_report_maxage {
|
||||
$puppet_report_maxage = "30"
|
||||
}
|
||||
|
||||
if $::operatingsystem != "OpenBSD" {
|
||||
if !$puppet_report_maxage {
|
||||
$puppet_report_maxage = "720"
|
||||
}
|
||||
file { "/etc/cron.daily/puppet-report-cleanup":
|
||||
ensure => present,
|
||||
content => template("puppet/puppet-report-cleanup.erb"),
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
require => [ File["/srv/puppet/reports"], Package["tmpwatch"] ],
|
||||
ensure => absent,
|
||||
}
|
||||
}
|
||||
|
||||
file { "/usr/local/sbin/puppet-report-cleanup":
|
||||
ensure => present,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
content => template("puppet/puppet-report-cleanup.erb"),
|
||||
require => File["/srv/puppet/reports"],
|
||||
}
|
||||
|
||||
cron { "puppet-report-cleanup":
|
||||
ensure => present,
|
||||
command => "/usr/local/sbin/puppet-report-cleanup",
|
||||
user => $user,
|
||||
hour => "1",
|
||||
minute => "5",
|
||||
require => File["/usr/local/sbin/puppet-report-cleanup"],
|
||||
}
|
||||
|
||||
if $puppet_storeconfigs != "none" {
|
||||
file { "/usr/local/sbin/puppet-clean-storeconfigs":
|
||||
ensure => present,
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
MAXAGE=<%= @puppet_report_maxage %>
|
||||
if [ "`whoami`" = "root" ]; then
|
||||
echo "$0: must not be run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/usr/sbin/tmpwatch -m ${MAXAGE} /srv/puppet/reports
|
||||
find /srv/puppet/reports/ -mindepth 2 -mmin +1440 -type f -name \*.yaml -exec gzip {} \;
|
||||
find /srv/puppet/reports/ -xdev -mindepth 2 -type f -mtime +<%= @puppet_report_maxage %> \
|
||||
-name '*.yaml.gz' -execdir rm -f -- {} \;
|
||||
find /srv/puppet/reports/ -xdev -mindepth 2 -type f -mtime +1 \
|
||||
-name '*.yaml' -execdir gzip -- {} \;
|
||||
|
|
Loading…
Add table
Reference in a new issue