Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternative logger path #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions files/etc/cron.daily/logrotate.sles
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE
# OVERWRITTEN.

OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.conf 2>&1)
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
echo "${OUTPUT}"
fi
exit $EXITVALUE
11 changes: 11 additions & 0 deletions files/etc/cron.hourly/logrotate.sles
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE
# OVERWRITTEN.

OUTPUT=$(/usr/sbin/logrotate /etc/logrotate.d/hourly 2>&1)
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
echo "${OUTPUT}"
fi
exit $EXITVALUE
32 changes: 19 additions & 13 deletions manifests/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
require => Package['logrotate'],
}

case $::osfamily {
'Debian': {
include logrotate::defaults::debian
$logrotate_file = 'logrotate'
}
'RedHat': {
include logrotate::defaults::redhat
$logrotate_file = 'logrotate'
}
'SuSE': {
include logrotate::defaults::suse
$logrotate_file = 'logrotate.sles'
}
default: {
$logrotate_file = 'logrotate'
}
}

file {
'/etc/logrotate.conf':
ensure => file,
Expand All @@ -25,19 +43,7 @@
'/etc/cron.daily/logrotate':
ensure => file,
mode => '0555',
source => 'puppet:///modules/logrotate/etc/cron.daily/logrotate';
source => "puppet:///modules/logrotate/etc/cron.daily/${logrotate_file}";
}

case $::osfamily {
'Debian': {
include logrotate::defaults::debian
}
'RedHat': {
include logrotate::defaults::redhat
}
'SuSE': {
include logrotate::defaults::suse
}
default: { }
}
}
12 changes: 11 additions & 1 deletion manifests/hourly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
}
}

case $::osfamily {
'SuSE': {
$logrotate_file = 'logrotate.sles'
}
default: {
$logrotate_file = 'logrotate'
}
}

file {
'/etc/logrotate.d/hourly':
ensure => $dir_ensure,
Expand All @@ -36,10 +45,11 @@
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/logrotate/etc/cron.hourly/logrotate',
source => "puppet:///modules/logrotate/etc/cron.hourly/${logrotate_file}",
require => [
File['/etc/logrotate.d/hourly'],
Package['logrotate'],
];
}

}