Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x
- Puppet >= 6.1.0 < 8.0.0
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppet-logrotate', '6.0.0'
Learn more about managing modules with a PuppetfileDocumentation
Logrotate module for Puppet
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 exceptions:
- Booleans are now used instead of the
<something>
/no<something>
pattern. e.g.copy
==copy => true
,nocopy
==copy => false
. create
and its three optional arguments have been split into seperate parameters documented below.- Instead of 'daily', 'weekly', 'monthly' or 'yearly', there is a
rotate_every
parameter (see documentation below).
logrotate::conf
You may, optionally, define logrotate defaults using this defined type.
Parameters are the same as those for logrotate::rule.
Using this type will automatically include a private class that will install
and configure logrotate for you.
You must not also declare the logrotate
class if using this defined type as you will encounter a Puppet error if you attempt to do so.
logrotate::rule
The only thing you'll need to deal with, this type configures a logrotate rule. Using this type will automatically include a private class that will install and configure logrotate for you.
namevar - The String name of the rule.
path - The path(s) to the log file(s) to be rotated. May be a
String or an Array of Strings.
ensure - The desired state of the logrotate rule as a String. Valid
values are 'absent' and 'present' (default: 'present').
compress - A Boolean value specifying whether the rotated logs should
be compressed (optional).
compresscmd - The command String that should be executed to compress the
rotated logs (optional).
compressext - The extention String to be appended to the rotated log files
after they have been compressed (optional).
compressoptions - A String of command line options to be passed to the
compression program specified in `compresscmd` (optional).
copy - A Boolean specifying whether logrotate should just take a
copy of the log file and not touch the original (optional).
copytruncate - A Boolean specifying whether logrotate should truncate the
original log file after taking a copy (optional).
create - A Boolean specifying whether logrotate should create a new
log file immediately after rotation (optional).
create_mode - An octal mode String logrotate should apply to the newly
created log file if create => true (optional).
create_owner - A username String that logrotate should set the owner of the
newly created log file to if create => true (optional).
create_group - A String group name that logrotate should apply to the newly
created log file if create => true (optional).
dateext - A Boolean specifying whether rotated log files should be
archived by adding a date extension rather just a number
(optional).
dateformat - The format String to be used for `dateext` (optional).
Valid specifiers are '%Y', '%m', '%d' and '%s'.
dateyesterday - A Boolean specifying whether to use yesterday's date instead
of today's date to create the `dateext` extension (optional).
delaycompress - A Boolean specifying whether compression of the rotated
log file should be delayed until the next logrotate run
(optional).
extension - Log files with this extension String are allowed to keep it
after rotation (optional).
ifempty - A Boolean specifying whether the log file should be rotated
even if it is empty (optional).
mail - The email address String that logs that are about to be
rotated out of existence are emailed to (optional).
mailfirst - A Boolean that when used with `mail` has logrotate email the
just rotated file rather than the about to expire file
(optional).
maillast - A Boolean that when used with `mail` has logrotate email the
about to expire file rather than the just rotated file
(optional).
maxage - The Integer maximum number of days that a rotated log file
can stay on the system (optional).
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
moved to (optional).
postrotate - A command String that should be executed by /bin/sh after
the log file is rotated (optional).
prerotate - A command String that should be executed by /bin/sh before
the log file is rotated and only if it will be rotated
(optional).
firstaction - A command String that should be executed by /bin/sh once
before all log files that match the wildcard pattern are
rotated (optional).
lastaction - A command String that should be execute by /bin/sh once
after all the log files that match the wildcard pattern are
rotated (optional).
rotate - The Integer number of rotated log files to keep on disk
(optional).
rotate_every - How often the log files should be rotated as a String.
Valid values are 'hour', 'day', 'week', 'month' and 'year'
(optional). Please note, older versions of logrotate do not
support yearly log rotation.
size - The String size a log file has to reach before it will be
rotated (optional). The default units are bytes, append k,
M or G for kilobytes, megabytes or gigabytes respectively.
sharedscripts - A Boolean specifying whether logrotate should run the
postrotate and prerotate scripts for each matching file or
just once (optional).
shred - A Boolean specifying whether logs should be deleted with
shred instead of unlink (optional).
shredcycles - The Integer number of times shred should overwrite log files
before unlinking them (optional).
start - The Integer number to be used as the base for the extensions
appended to the rotated log files (optional).
su_user - A username String that logrotate should use to rotate a
log file set instead of using the default if
su => true (optional).
su_group - A String group name that logrotate should use to rotate a
log file set instead of using the default if
su => true (optional).
uncompresscmd - The String command to be used to uncompress log files
(optional).
Further details about these options can be found by reading man 8 logrotate
.
logrotate
You may, optionally, declare the main ::logrotate
class to adjust some of the
defaults that are used when installing 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.
class { '::logrotate':
ensure => 'latest',
config => {
dateext => true,
compress => true,
rotate => 10,
rotate_every => 'week',
ifempty => true,
}
}
Additional startup arguments
With parameter logrotate_args
you can specify additional startup arguments for logrotate. Configuration file is always added as the last argument for logrotate.
This example tells logrotate to use an alternate state file and which command to use when mailing logs.
class { '::logrotate':
ensure => 'latest',
logrotate_args => ['-s /var/lib/logrotate/logrotate.status', '-m /usr/local/bin/mailer']
}
Cron output
By default, the cron output is discarded if there is no error output. To enable this output, when you (for example) enable the verbose startup argument, enable the cron_always_output
boolean on the logrotate class:
class { '::logrotate':
ensure => 'latest',
cron_always_output => true,
config => {
...
}
}
Examples
logrotate::conf { '/etc/logrotate.conf':
rotate => 10,
rotate_every => 'week',
ifempty => true,
dateext => true,
}
logrotate::rule { 'messages':
path => '/var/log/messages',
rotate => 5,
rotate_every => 'week',
postrotate => '/usr/bin/killall -HUP syslogd',
}
logrotate::rule { 'servicelogs':
path => ['/var/log/this-service.log', '/var/log/that-app.log'],
rotate => 5,
rotate_every => 'day',
postrotate => '/usr/bin/kill -HUP `cat /run/syslogd.pid`',
}
logrotate::rule { 'apache':
path => '/var/log/httpd/*.log',
rotate => 5,
mail => 'test@example.com',
size => '100k',
sharedscripts => true,
postrotate => '/etc/init.d/httpd restart',
}
Authors and Module History
Puppet-logrotate has been maintained by VoxPupuli since version 2.0.0. It was migrated from https://forge.puppet.com/yo61/logrotate. yo61's version was a fork of https://github.com/rodjek/puppet-logrotate. It is licensed under the MIT license.
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v6.0.0 (2021-09-28)
Breaking changes:
- Drop EoL Puppet 5. Ubuntu 16 and Debian 8 support #185 (bastelfreak)
- Drop EOL EL6 support #179 (ekohl)
- Fix cron management #174 (crazymind1337)
Implemented enhancements:
- Enable Puppet 7 support #184 (bastelfreak)
Closed issues:
- version 4 doesn't obey manage_cron_daily parameter #161
- how to disable file { $logrotate::cron_hourly_file: in hourly.pp #103
Merged pull requests:
- Allow stdlib 8.0.0 #182 (smortex)
- Resolve puppet-lint notices #175 (jcpunk)
- modulesync 3.0.0 & puppet-lint updates #173 (bastelfreak)
- Use voxpupuli-acceptance #172 (ekohl)
v5.0.0 (2020-04-04)
Breaking changes:
- drop Ubuntu 14.04 support #163 (bastelfreak)
Implemented enhancements:
- Add
custom_cfg
parameter tologrotate::rule
allowing custom lines to be appended to rule files #66 (triforce)
Fixed bugs:
Closed issues:
- Wrong logrotate bin path with Gentoo #167
Merged pull requests:
v4.0.0 (2019-09-19)
Breaking changes:
- modulesync 2.7.0 and drop puppet 4 #147 (bastelfreak)
Implemented enhancements:
- "su" and "su_owner" parameters are not accepted in "conf" #40
- Use modern facts and $facts hash for osfamily #151 (simmerz)
- Introduce new top level parameter manage_cron_hourly which defaults … #137 (cliff-wakefield)
Closed issues:
- Unable to disable cron for hourly rotations #136
Merged pull requests:
- Allow puppetlabs-stdlib 6 #156 (jaredledvina)
- Remove deprecated and unused is_hash function #155 (baurmatt)
- Remove occurences of su_owner #148 (adriankirchner)
- Document possible use of Array for paths #145 (dleske)
v3.4.0 (2018-10-06)
Breaking changes:
Implemented enhancements:
- add support for Debian 8/9 and Ubuntu 18.04 #134 (rj667)
- Rebase(2) of Pull Request #80 #128 (Heidistein)
- Enforce minimal string length on logrotate arguments. #127 (Heidistein)
- Allow cron to always mail its output. #124 (Heidistein)
Fixed bugs:
- Fix params for Ubuntu to ensure su is set #138 (acurus-puppetmaster)
Closed issues:
- Rerelease 3.3.0 as 3.3.1 #121
- Missing tag and Puppet Forge release for 3.3.0 #120
- check debian support #114
Merged pull requests:
- modulesync 2.0.0 #142 (dhollinger)
- Release 3.4.0 and allow puppet 6.x #141 (dhollinger)
- enable acceptance tests centos 6/7 ubuntu 14/16 #135 (bastelfreak)
- allow puppetlabs/stdlib 5.x #132 (bastelfreak)
v3.3.0 (2018-06-25)
Implemented enhancements:
- Allow change of file mode for generated files #70
- Fix freebsd default rules #111 (kapouik)
- Fix Issue 70 add file mode parameters #109 (TJM)
- Use logrotate::cron rather than file resource for hourly cron #105 (pavloos)
- Manage logrotate startup arguments #102 (ruriky)
Closed issues:
- duplicate resource or dependency cycle when attempting to set default options #116
Merged pull requests:
- (docs) Update readme with warning note and bigger example of defaults #117 (GeoffWilliams)
- Remove docker nodesets #115 (bastelfreak)
- drop EOL OSs; fix puppet version range #113 (bastelfreak)
v3.2.1 (2018-03-28)
Merged pull requests:
- bump puppet to latest supported version 4.10.0 #107 (bastelfreak)
v3.2.0 (2018-01-04)
Implemented enhancements:
- Deprecation warnings from newer stdlib #54
- Add option to not manage logrotate package #44
- Add manage_package parameter #97 (juniorsysadmin)
- Make the creation of default [bw]tmp-rulesets configurable #65 (mcgege)
- Add purge_configdir to purge old configs #23 (patricktoelle)
Fixed bugs:
- 'su root syslog' line missing in default logrotate.conf file for Ubuntu produced by this module #93
- Pattern matcher in Logrotate::UserOrGroup is too strict. Doesn't allow names with domain. #88
- Enum on package ensure is too restrictive #84
- logrotate::conf[/etc/logrotate.conf] #49
- copy and copytruncate marked in rules.pp as optional #31
- copytruncate => true affects logrotate::defaults wtmp and btmp rules #22
- Remove UserOrGroup type, use String #98 (juniorsysadmin)
- Allow logrotate version to be specified #96 (juniorsysadmin)
- Fix missing su line in default logrotate.conf on Ubuntu #92 (szponek)
- Add missing $maxsize option to Logrotate::Conf #90 (achermes)
Closed issues:
- parameter 'path' references an unresolved type 'Stdlib::UnixPath' #95
- logrotate::rule adds blank su to wtmp and btmp #41
- Add tests for all OSes for defaults.pp #3
Merged pull requests:
- Remove obsolete su parameter in documentation #91 (stefanandres)
v3.1.0 (2017-11-13)
Implemented enhancements:
- Allow dateyesterday at the global level #83 (cliff-wakefield)
Fixed bugs:
Closed issues:
- Config is not a string but a hash #77
- Support Ubuntu 16.04 #59
- Does this module attempt to apply the defaults for the GNU distribution? #48
v3.0.1 (2017-10-14)
Fixed bugs:
- wrong datatype for $config, s/String/Hash #78 (bastelfreak)
v3.0.0 (2017-10-10)
Closed issues:
- Remove old CHANGELOG or merge with CHANGELOG.md #69
Merged pull requests:
- Fix changelog #73 (alexjfisher)
- Added support for dateyesterday within logrotate::rule #71 (cliff-wakefield)
- BREAKING: Introduce Puppet 4 datatypes and drop Puppet 3 support #68 (mmerfort)
v2.0.0 (2017-05-25)
Closed issues:
- Logrotate rule ERB template should not take variables from the scope object #37
- Ubuntu Xenial 16.04 compaibility #34
- string 'undef' now treated as undef #26
- Allow adjustment of OS-specific defaults #9
Merged pull requests:
- Fix typo #58 (gabe-sky)
- Adding support for maxsize also in main config #57 (seefood)
- Fix rubocop checks #53 (coreone)
- Fixes #34 - Ubuntu Xenial and up support #43 (edestecd)
- Fixes #37 - Logrotate rule ERB template should not take variables from the scope object #38 (imriz)
- Fix puppet-lint issues and bad style #32 (baurmatt)
- Add gentoo support #27 (baurmatt)
v1.4.0 (2016-05-30)
Closed issues:
- Optional config settings are no longer optional?!? #29
- wtmp and btmp are different when using the future parser #13
Merged pull requests:
- Changed default string "undef" to "UNDEFINED" to work around this bug… #28 (durist)
- Fix typo in README.md #25 (siebrand)
- Added ability to override default btmp and/or wtmp #21 (ncsutmf)
- remove special whitespace character #20 (jfroche)
- Update Gemfile for Rake/Ruby version dependencies #19 (ncsutmf)
- add official puppet 4 support #17 (mmckinst)
v1.3.0 (2015-11-05)
Closed issues:
- The logrotate package should be 'present' by default, or at least tunable #11
Merged pull requests:
- Set default package ensure value to 'installed' #12 (natemccurdy)
- Add support for maxsize directive #10 (zeromind)
v1.2.8 (2015-09-14)
- Fix hidden unicode character (#8)
- Allow config to be passed in as an hash (#6)
- Fix dependency issue (#7)
- refactor main class (mostly to facilitate #7)
- update test environment to use puppet 4
- switch stdlib fixture to https source
v1.2.7 (2015-05-06)
- Metadata-only release (just bumped version)
v1.2.6 (2015-05-06)
- Fix test failures on future parser
v1.2.5 (2015-05-06)
- Switch some validation code to use validate_re
v1.2.4 (2015-05-06)
- Add puppet-lint exclusions
v1.2.3 (2015-05-06)
- More work on testing
- fix warning when running puppet module list caused by "-" instead of "/" in dependencies in metadata
v1.2.3 (2015-05-06)
- removed (pushed without CHANGELOG update
v1.2.1 (2015-05-06)
- Update tests, Rakefile, etc.
v1.2.0 (2015-03-25)
- First release to puppetforge
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/stdlib (>= 4.22.0 < 9.0.0)
Copyright (c) 2012 Tim Sharpe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.