This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
forked from rodjek/puppet-logrotate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rodjek#11 from rodjek/hourly
Add support for hourly logrotate jobs
- Loading branch information
Showing
5 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
# THIS FILE IS AUTOMATICALLY DISTRIBUTED BY PUPPET. ANY CHANGES WILL BE | ||
# OVERWRITTEN. | ||
|
||
test -x /usr/sbin/logrotate || exit 0 | ||
/usr/sbin/logrotate /etc/logrotate.d/hourly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Internal: Configure a host for hourly logrotate jobs. | ||
# | ||
# ensure - The desired state of hourly logrotate support. Valid values are | ||
# 'absent' and 'present' (default: 'present'). | ||
# | ||
# Examples | ||
# | ||
# # Set up hourly logrotate jobs | ||
# include logrotate::hourly | ||
# | ||
# # Remove hourly logrotate job support | ||
# class { 'logrotate::hourly': | ||
# ensure => absent, | ||
# } | ||
class logrotate::hourly($ensure='present') { | ||
case $ensure { | ||
'absent': { | ||
$dir_ensure = $ensure | ||
} | ||
'present': { | ||
$dir_ensure = 'directory' | ||
} | ||
default: { | ||
fail("Class[Logrotate::Hourly]: Invalid ensure value '${ensure}'") | ||
} | ||
} | ||
|
||
file { | ||
'/etc/logrotate.d/hourly': | ||
ensure => $dir_ensure, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0755'; | ||
'/etc/cron.hourly/logrotate': | ||
ensure => $ensure, | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0555', | ||
source => 'puppet:///modules/logrotate/etc/cron.hourly/logrotate', | ||
require => [ | ||
File['/etc/logrotate.d/hourly'], | ||
Package['logrotate'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
|
||
describe 'logrotate::hourly' do | ||
context 'with default values' do | ||
it do | ||
should contain_file('/etc/logrotate.d/hourly').with({ | ||
'ensure' => 'directory', | ||
'owner' => 'root', | ||
'group' => 'root', | ||
'mode' => '0755', | ||
}) | ||
end | ||
|
||
it do | ||
should contain_file('/etc/cron.hourly/logrotate').with({ | ||
'ensure' => 'present', | ||
'owner' => 'root', | ||
'group' => 'root', | ||
'mode' => '0555', | ||
'source' => 'puppet:///modules/logrotate/etc/cron.hourly/logrotate', | ||
'require' => [ | ||
'File[/etc/logrotate.d/hourly]', | ||
'Package[logrotate]', | ||
], | ||
}) | ||
end | ||
end | ||
|
||
context 'with ensure => absent' do | ||
let(:params) { {:ensure => 'absent'} } | ||
|
||
it { should contain_file('/etc/logrotate.d/hourly').with_ensure('absent') } | ||
it { should contain_file('/etc/cron.hourly/logrotate').with_ensure('absent') } | ||
end | ||
|
||
context 'with ensure => foo' do | ||
let(:params) { {:ensure => 'foo'} } | ||
|
||
it do | ||
expect { | ||
should contain_file('/etc/logrotate.d/hourly') | ||
}.to raise_error(Puppet::Error, /Invalid ensure value 'foo'/) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters