Version information
Start using this module
Add this module to your Puppetfile:
mod 'geoffwilliams-logrotate', '0.1.1'
Learn more about managing modules with a PuppetfileDocumentation
logrotate
Table of Contents
- Description
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Description
Manage logrotate with puppet using in-place editing
Usage
See reference and examples
Limitations
- Not supported by Puppet, Inc.
Development
PRs accepted :)
Testing
This module supports testing using PDQTest.
Test can be executed with:
bundle install
make
See .travis.yml
for a working CI example
Reference
Table of Contents
Classes
logrotate
: Install and configure log rotation on Linux
Defined types
logrotate::entry
: Create a log rotate entry under/etc/logrotate.d
.
Functions
logrotate::find_match
: convert the passed string to a regex to search with
Classes
logrotate
Management of /etc/logrotate.conf
is performed as edits to avoid
clobbering vendor defaults.
The module takes the position that the files laid down by the vendor are correct and only modifies them the minimal amount needed to make the system work - users/admins are trusted not alter files away from the defaults.
Examples
Install logrotate with vendor configuration
include logrotate
Hiera default settings
logrotate::settings:
weekly:
rotate: 4
create:
dateext:
compress:
Hiera logrotate entries (custom rules)
lograte::entries:
/var/log/messages:
/var/log/myapp:
settings:
rotate: 50
Parameters
The following parameters are available in the logrotate
class.
package
Data type: String
Name of the package providing logrotate
Default value: "logrotate"
settings
Data type: Hash[String,Any]
Hash of default settings for logrotate.conf
(see examples)
Default value: {}
entries
Data type: Hash[String,Hash[String,Any]]
Hash of logrotate entries to create (see examples)
Default value: {}
Defined types
logrotate::entry
Config file to write is guessed by taking the basename of log_file
unless config_file
is passed explicitly (eg /var/log/yum.log
would create a file at
/etc/logrotate.d/yum.log
).
Logrotate will take settings from the main configuration file at /etc/logrotate.conf
unless they are individually overriden in the settings
hash
Examples
logrotate settings in the default location using default settings
logrotate::entry { "/var/log/yum.log":}
logrotate settings in the default location using custom settings
logrotate::entry { "/var/log/yum.log":
settings => {
"rotate" => 13,
"nocreate" => undef,
},
}
logrotate settings in custom location using custom settings
logrotate::entry { "/var/log/yum.log":
config_file => "package_log.txt",
settings => {
"rotate" => 13,
"nocreate" => undef,
},
}
managing multiple log files from a single configuration file
logrotate::entry { "stuff":
log_file => "/var/log/yum.log, /var/log/messages, /var/log/btmp",
settings => {
"rotate" => 50,
},
}
Parameters
The following parameters are available in the logrotate::entry
defined type.
config_file
Data type: Optional[String]
Config file to create under /etc/logrotate.d
. A default value will be
picked for you based on title
if omitted
Default value: undef
log_file
Data type: Optional[String]
File(s) to rotate via the config file
Default value: undef
settings
Data type: Hash[String, Any]
Hash of settings to add to config file (see examples)
Default value: {}
header
Data type: String
Warning message to add to the top of the config file
Default value: "# managed by puppet, do not edit!"
Functions
logrotate::find_match
Type: Puppet Language
Figure out the regexp we need to use with fm_replace
in order to update the passed in setting
logrotate::find_match(Any $setting)
Figure out the regexp we need to use with fm_replace
in order to update the passed in setting
Returns: String
representing the regex to match the main config file for
setting
Data type: Any
The setting to match (eg "weekly")
Dependencies
- puppetlabs-stdlib (>= 1.0.0)
- geoffwilliams-filemagic (0.5.1)