Showing with 46 additions and 7 deletions.
  1. +4 −0 CHANGELOG
  2. +4 −0 CONTRIBUTORS
  3. +27 −3 README.md
  4. +1 −1 manifests/init.pp
  5. +7 −0 manifests/rule.pp
  6. +1 −1 metadata.json
  7. +1 −1 spec/classes/init_spec.rb
  8. +1 −1 templates/etc/logrotate.d/rule.erb
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2015-11-05 Release 1.3.0
- set default package version to "present" rather than "latest" (#11) (natemccurdy)
- add documentation for setting class defaults (natemccurdy)

2015-09-14 Release 1.2.8
- Fix hidden unicode character (#8)
- Allow config to be passed in as an hash (#6)
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
Andreas Ntaflos
Atom Powers
Daniel Beckham
David Collom
Jurgen Weber
Keith McDuffee
Mason Malone
Matthias Kneer
Michael Moll
Mick Pollard
Nate McCurdy
Nathan Huff
Nicolas Jehle
Robin Bowes
Tim Sharpe
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Logrotate module for Puppet

## Disclaimer
## Disclaimer

This module is a fork of https://github.com/rodjek/puppet-logrotate merging some of the outstanding pull requests

I have also added the puppetlabs_spec_help functionality as used in [Gareth Rushgrove](https://github.com/garethr)'s [puppet-module-skeleton](https://github.com/garethr/puppet-module-skeleton).

## Description
## Description

A more Puppety way of managing logrotate configs. Where possible, as many of
the configuration options have remained the same with a couple of notable
Expand Down Expand Up @@ -83,6 +83,11 @@ minsize - The String minimum size a log file must be to be rotated,
but not before the scheduled rotation time (optional).
The default units are bytes, append k, M or G for kilobytes,
megabytes and gigabytes respectively.
maxsize - The String maximum size a log file may be to be rotated;
When maxsize is used, both the size and timestamp of a log
file are considered for rotation.
The default units are bytes, append k, M or G for kilobytes,
megabytes and gigabytes respectively.
missingok - A Boolean specifying whether logrotate should ignore missing
log files or issue an error (optional).
olddir - A String path to a directory that rotated logs should be
Expand Down Expand Up @@ -131,9 +136,28 @@ uncompresscmd - The String command to be used to uncompress log files

Further details about these options can be found by reading `man 8 logrotate`.

### Examples
## logrotate

You may, optionally, declare the main `::logrotate` class to adjust some of the
defaults that are used when intalling the logrotate package and creating the
main `/etc/logrotate.conf` configuration file.

This example will ensure that the logrotate package is latest and that the `dateext` and `compress` options are added to the defaults for a node.

```puppet
class { '::logrotate':
ensure => 'latest',
config => {
dateext => true,
compress => true,
}
}
```


## Examples

```puppet
logrotate::conf { '/etc/logrotate.conf':
rotate => 10,
rotate_every => 'week',
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
class logrotate (
$ensure = 'latest',
$ensure = present,
$hieramerge = false,
$manage_cron_daily = true,
$package = 'logrotate',
Expand Down
7 changes: 7 additions & 0 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
# but not before the scheduled rotation time (optional).
# The default units are bytes, append k, M or G for kilobytes,
# megabytes and gigabytes respectively.
# maxsize - The String maximum size a log file may be to be rotated;
# When maxsize is used, both the size and timestamp of a log
# file are considered for rotation.
# The default units are bytes, append k, M or G for kilobytes,
# megabytes and gigabytes respectively.
# missingok - A Boolean specifying whether logrotate should ignore missing
# log files or issue an error (optional).
# olddir - A String path to a directory that rotated logs should be
Expand Down Expand Up @@ -139,6 +144,7 @@
$maillast = 'undef',
$maxage = 'undef',
$minsize = 'undef',
$maxsize = 'undef',
$missingok = 'undef',
$olddir = 'undef',
$postrotate = 'undef',
Expand Down Expand Up @@ -299,6 +305,7 @@
# Any better ideas greatfully received
validate_re("X${maxage}", ['^Xundef$', '^X\d+$'], "Logrotate::Conf[${name}]: maxage must be an integer")
validate_re("X${minsize}", ['^Xundef$', '^X\d+[kMG]?$'], "Logrotate::Conf[${name}]: minsize must match /\\d+[kMG]?/")
validate_re("X${maxsize}", ['^Xundef$', '^X\d+[kMG]?$'], "Logrotate::Conf[${name}]: maxsize must match /\\d+[kMG]?/")
validate_re("X${rotate}", ['^Xundef$', '^X\d+$'], "Logrotate::Conf[${name}]: rotate must be an integer")
validate_re("X${size}", ['^Xundef$', '^X\d+[kMG]?$'], "Logrotate::Conf[${name}]: size must match /\\d+[kMG]?/")
validate_re("X${shredcycles}", ['^Xundef$', '^X\d+$'], "Logrotate::Conf[${name}]: shredcycles must be an integer")
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yo61-logrotate",
"version": "1.2.8",
"version": "1.3.0",
"author": "Robin Bowees <robin.bowes@yo61.com>",
"summary": "Manage logrotate",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it { is_expected.to compile.with_all_deps }

it do
should contain_package('logrotate').with_ensure('latest')
should contain_package('logrotate').with_ensure('present')

# should contain_file('/etc/logrotate.conf').with({
# 'ensure' => 'file',
Expand Down
2 changes: 1 addition & 1 deletion templates/etc/logrotate.d/rule.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

[
'compresscmd', 'compressext', 'compressoptions', 'dateformat', 'extension',
'maxage', 'minsize', 'rotate', 'size', 'shredcycles', 'start',
'maxage', 'minsize', 'maxsize', 'rotate', 'size', 'shredcycles', 'start',
'uncompresscmd'
].each do |key|
value = scope.to_hash[key]
Expand Down