Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
- Puppet >= 4.10.0 < 7.0.0
Start using this module
Add this module to your Puppetfile:
mod 'marionetoj-logrotate', '0.3.0'
Learn more about managing modules with a PuppetfileDocumentation
logrotate
Manage Logrotate base configuration and rules.
Table of Contents
- Description
- Usage - Configuration options and additional functionality
- Limitations - OS compatibility, etc.
- Contributing - Guide for contributing to the module
Description
From logrotate
’s documentation:
logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.
Usage
This module's default values should be the same as your distribution defaults:
include logrotate
But you can customize everything:
class { '::logrotate':
purge_unmanaged_rules => false,
global_settings => {
compress => true,
create => true,
ifempty => false,
missingok => true,
rotate => 30,
frequency => 'daily',
copytruncate => true,
},
}
You can then create rules with the logrotate::rule
defined type:
logrotate::rule { '/var/log/syslog':
rotate => 7,
frequency => 'daily',
missingok => true,
ifempty => false,
delaycompress => true,
compress => true,
postrotate => [
'/usr/lib/rsyslog/rsyslog-rotate',
]
}
Reference
A complete reference can be found in the REFERENCE.md file.
Limitations
This module has only been tested on Debian 9 and 10, but it should work with older and newer version as well as with Ubuntu 18.04 and later.
Contributing
This Puppet module is Free Software, every contributions are welcome.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Reference
Table of Contents
Classes
Public Classes
logrotate
: Install and configure logrotate
Private Classes
logrotate::config
:logrotate::cron
:logrotate::install
:
Defined types
logrotate::rule
: Manage a logrotate rule
Classes
logrotate
Install and configure logrotate
Examples
Basic usage
class { '::logrotate':
purge_config_dir => false,
global_settings => {
compress => true,
create => true,
ifempty => false,
missingok => true,
rotate => 30,
frequency => 'daily',
copytruncate => true,
},
}
Parameters
The following parameters are available in the logrotate
class.
manage_package
Data type: Boolean
Wether the package resource should be managed.
package_name
Data type: String
Name of the package that installs logrotate.
package_ensure
Data type: String
Define the ensure parameter for the logrotate package.
config_file
Data type: Stdlib::AbsolutePath
Absolute path to logrotate's global configuration file (e.g. /etc/logrotate.conf).
config_dir
Data type: Stdlib::AbsolutePath
Absolute path to logrotate's rule files directory (e.g. /etc/logrotate.d).
purge_unmanaged_rules
Data type: Boolean
Weither or not to purge the configuration directory from unmanaged rules.
manage_cron
Data type: Boolean
Wether the cron entry should be managed.
cron_frequency
Data type: Pattern[/(hourly|daily|weekly|monthly)/]
The frequency at which cron should run.
global_settings
Data type: Hash
The global settings to put in the global configuration file
rules
Data type: Hash
A Hash of logrotate::rule
to be passed to create_resources
Default value: {}
Defined types
logrotate::rule
Most of logrotate directives are kept the same except for:
- frequency (houtly, daily, weekly, monthly) which is set via the
frequency
parameter. - Directives that can be negated (e.g.
create
/nocreate
) are specified as Boolean (e.g.create => true
/create => false
). create
,createolddir
andsu
are split into multiple parameters
Examples
Basic usage
logrotate::rule { '/var/log/syslog':
rotate => 7,
frequency => 'daily',
missingok => true,
ifempty => false,
delaycompress => true,
compress => true,
postrotate => [
'/usr/lib/rsyslog/rsyslog-rotate',
]
}
Parameters
The following parameters are available in the logrotate::rule
defined type.
filename
Data type: Optional[Stdlib::AbsolutePath]
Default value: undef
template
Data type: Optional[String]
Default value: undef
paths
Data type: Optional[Array[String]]
Default value: undef
frequency
Data type: Optional[Variant[Pattern[/(hourly|daily|weekly|monthly)/], Integer]]
Default value: undef
compress
Data type: Optional[Boolean]
Default value: undef
compresscmd
Data type: Optional[String]
Default value: undef
uncompresscmd
Data type: Optional[String]
Default value: undef
compressext
Data type: Optional[String]
Default value: undef
compressoptions
Data type: Optional[String]
Default value: undef
copy
Data type: Optional[Boolean]
Default value: undef
copytruncate
Data type: Optional[Boolean]
Default value: undef
create
Data type: Optional[Boolean]
Default value: undef
create_mode
Data type: Optional[String]
Default value: undef
create_owner
Data type: Optional[String]
Default value: undef
create_group
Data type: Optional[String]
Default value: undef
createolddir
Data type: Optional[Boolean]
Default value: undef
createolddir_mode
Data type: Optional[String]
Default value: undef
createolddir_owner
Data type: Optional[String]
Default value: undef
createolddir_group
Data type: Optional[String]
Default value: undef
dateext
Data type: Optional[Boolean]
Default value: undef
dateformat
Data type: Optional[String]
Default value: undef
dateyesterday
Data type: Optional[Boolean]
Default value: undef
delaycompress
Data type: Optional[Boolean]
Default value: undef
extension
Data type: Optional[String]
Default value: undef
addextension
Data type: Optional[String]
Default value: undef
ifempty
Data type: Optional[Boolean]
Default value: undef
include
Data type: Optional[String]
Default value: undef
mail
Data type: Optional[String]
Default value: undef
mailfirst
Data type: Optional[String]
Default value: undef
maillast
Data type: Optional[String]
Default value: undef
minage
Data type: Optional[Integer]
Default value: undef
maxage
Data type: Optional[Integer]
Default value: undef
maxsize
Data type: Optional[Integer]
Default value: undef
minsize
Data type: Optional[Integer]
Default value: undef
missingok
Data type: Optional[Boolean]
Default value: undef
olddir
Data type: Optional[String]
Default value: undef
postrotate
Data type: Optional[Array[String]]
Default value: undef
prerotate
Data type: Optional[Array[String]]
Default value: undef
firstaction
Data type: Optional[Array[String]]
Default value: undef
lastaction
Data type: Optional[Array[String]]
Default value: undef
preremove
Data type: Optional[Array[String]]
Default value: undef
rotate
Data type: Optional[Integer]
Default value: undef
renamecopy
Data type: Optional[Boolean]
Default value: undef
size
Data type: Optional[Integer]
Default value: undef
sharedscripts
Data type: Optional[Boolean]
Default value: undef
shred
Data type: Optional[Boolean]
Default value: undef
shredcycles
Data type: Optional[Integer]
Default value: undef
start
Data type: Optional[Integer]
Default value: undef
su
Data type: Optional[Boolean]
Default value: undef
su_user
Data type: Optional[String]
Default value: undef
su_group
Data type: Optional[String]
Default value: undef
Dependencies
- puppetlabs-stdlib (>= 4.0.0 < 7.0.0)
- camptocamp-systemd (>= 2.0.0 < 3.0.0)