Skip to content

Latest commit

 

History

History
1344 lines (786 loc) · 34.2 KB

REFERENCE.md

File metadata and controls

1344 lines (786 loc) · 34.2 KB

Reference

Table of Contents

Classes

Public Classes

Private Classes

  • logrotate::config: Configure logrotate
  • logrotate::defaults: Apply module defaults
  • logrotate::hourly: Configure a host for hourly logrotate jobs.
  • logrotate::install: Make sure logrotate is installed
  • logrotate::params: Logrotate module default configuration settings/Params class
  • logrotate::rules: Apply user-defined rules

Defined types

Data types

Classes

logrotate

Install and configure logrotate

Parameters

The following parameters are available in the logrotate class:

ensure

Data type: String

Desired installation state for the logrotate package

Default value: present

manage_cron_daily

Data type: Boolean

Manage logrotate daily cron file

Default value: true

manage_cron_hourly

Data type: Boolean

Manage logrotate hourly cron file

Default value: true

ensure_cron_daily

Data type: Enum[present,absent]

Ensure logrotate daily cron file is present/absent

Default value: 'present'

ensure_cron_hourly

Data type: Enum[present,absent]

Ensure logrotate hourly cron file is present/absent

Default value: 'present'

manage_systemd_timer

Data type: Boolean

Manage logrotate systemd timer

Default value: false

ensure_systemd_timer

Data type: Enum[present,absent]

Ensure logrotate systemd timer is present/absent

Default value: 'absent'

ensure_systemd_timer_hourly

Data type: Enum[present,absent]

Ensure logrotate systemd hourly timer is present/absent

Default value: 'absent'

create_base_rules

Data type: Boolean

Create base rules (for example btmp, wtmp)

Default value: true

purge_configdir

Data type: Boolean

Purge logrotate files not managed by the module.

Default value: false

package

Data type: String

Logrotate package name.

Default value: 'logrotate'

rules

Data type: Hash

Hash of logrotate logrotate::rule rules

Default value: {}

config

Data type: Optional[Hash]

Hash of default config values for logrotate

Default value: undef

cron_daily_hour

Data type: Integer[0,23]

Hour at which daily logrotate cron is executed

Default value: $logrotate::params::cron_daily_hour

cron_daily_minute

Data type: Integer[0,59]

Minute at which daily logrotate cron is executed

Default value: $logrotate::params::cron_daily_minute

cron_hourly_minute

Data type: Integer[0,59]

Minute at which hourly logrotate cron is executed

Default value: $logrotate::params::cron_hourly_minute

cron_file_mode

Data type: Stdlib::Filemode

Cron file permissions in numeric mode

Default value: $logrotate::params::cron_file_mode

configdir

Data type: String

Path of config dir

Default value: $logrotate::params::configdir

logrotate_bin

Data type: String

Path of logrotate binary

Default value: $logrotate::params::logrotate_bin

logrotate_conf

Data type: String

Path of logrotate.conf

Default value: $logrotate::params::logrotate_conf

logrotate_conf_mode

Data type: Stdlib::Filemode

Path of logrotate.conf

Default value: $logrotate::params::logrotate_conf_mode

manage_package

Data type: Boolean

Whether to manage logrtotate package

Default value: $logrotate::params::manage_package

rules_configdir

Data type: String

Path in which logrotate rules are created.

Default value: $logrotate::params::rules_configdir

rules_configdir_mode

Data type: Stdlib::Filemode

Logrotate rules folder permissions in numeric mode.

Default value: $logrotate::params::rules_configdir_mode

root_user

Data type: String

Name of root user.

Default value: $logrotate::params::root_user

root_group

Data type: String

Name of root group.

Default value: $logrotate::params::root_group

logrotate_args

Data type: Array[String[1]]

Arguments passed to logrotate.

Default value: []

cron_always_output

Data type: Boolean

Do not discard cron output when there is no error.

Default value: false

Defined types

logrotate::conf

Install and configure logrotate defaults file (usually /etc/logrotate.conf)

Examples

Configure /etc/logrotate.conf with defaults + configure shred
logrotate::conf {
   shred => true,
 }
Configure /etc/logrotate.conf to use zstd with non-default level
logrotate::conf {
  compress        => true,
  compresscmd     => '/usr/bin/zstd',
  compressext     => '.zst',
  compressoptions => '--compress -19',
  uncompresscmd   => '/usr/bin/unzstd',
}
ignore only *.foo files
logrotate::conf {
  tabooext => '.foo'
}
add *.foo and *.bar to ignored files, but still ignore defaults (.rpmsave for example)
logrotate::conf {
  tabooext => ['+','.foo','.bar'],
}

Parameters

The following parameters are available in the logrotate::conf defined type:

path

Data type: Stdlib::Unixpath

Path of the logrotate.conf file to manage.

Default value: $name

ensure

Data type: Enum['absent','present']

Desired state for the logrotate.conf file.

Default value: 'present'

compress

Data type: Optional[Boolean]

A Boolean value specifying whether the rotated logs should be compressed.

Default value: undef

compresscmd

Data type: Optional[String]

The command String that should be executed to compress the rotated logs.

Default value: undef

compressext

Data type: Optional[String]

The extention String to be appended to the rotated log files after they have been compressed.

Default value: undef

compressoptions

Data type: Optional[String]

A String of command line options to be passed to the compression program specified in compresscmd.

Default value: undef

copy

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should just take a copy of the log files and not touch the original.

Default value: undef

copytruncate

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should truncate the original log file after taking a copy.

Default value: undef

create

Data type: Boolean

A Boolean specifying whether logrotate should create new log files immediately after rotation.

Default value: true

create_mode

Data type: Optional[String]

An octal mode String logrotate should apply to the newly created log files if create => true.

Default value: undef

create_owner

Data type: Optional[String]

A username String that logrotate should set the owner of the newly created log files to if create => true.

Default value: undef

create_group

Data type: Optional[String]

A String group name that logrotate should apply to the newly created log files if create => true.

Default value: undef

dateext

Data type: Optional[Boolean]

A Boolean specifying whether rotated log files should be archived by adding a date extension rather just a number.

Default value: undef

dateformat

Data type: Optional[String]

The format String to be used for dateext . Valid specifiers are '%Y', '%m', '%d' and '%s'.

Default value: undef

dateyesterday

Data type: Optional[Boolean]

A Boolean specifying whether to use yesterday's date instead of today's date to create the dateext extension.

Default value: undef

delaycompress

Data type: Optional[Boolean]

A Boolean specifying whether compression of the rotated log file should be delayed until the next logrotate run.

Default value: undef

extension

Data type: Optional[String]

Log files with this extension String are allowed to keep it after rotation.

Default value: undef

ifempty

Data type: Optional[Boolean]

A Boolean specifying whether the log file should be rotated even if it is empty.

Default value: undef

mail

Data type: Optional[Variant[String,Boolean]]

The email address String that logs that are about to be rotated out of existence are emailed to.

Default value: undef

mail_when

Data type: Optional[Enum['mailfirst', 'maillast']]

When mail is configured, enable mailfirst (email the just rotated file rather than the about to expire file) and/or maillast (email the about to expire file rather than the just rotated file) behaviours.

Default value: undef

maxage

Data type: Optional[Integer]

The Integer maximum number of days that a rotated log file can stay on the system.

Default value: undef

minsize

Data type: Optional[Logrotate::Size]

The String minimum size a log file must be to be rotated, but not before the scheduled rotation time. The default units are bytes, append k, M or G for kilobytes, megabytes and gigabytes respectively.

Default value: undef

maxsize

Data type: Optional[Logrotate::Size]

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.

Default value: undef

missingok

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should ignore missing log files or issue an error.

Default value: undef

olddir

Data type: Optional[Variant[Boolean,String]]

A String path to a directory that rotated logs should be moved to.

Default value: undef

postrotate

Data type: Optional[String]

A command String or an Array of Strings that should be executed by /bin/sh after the log file is rotated optional).

Default value: undef

prerotate

Data type: Optional[String]

A command String or an Array of Strings that should be executed by /bin/sh before the log file is rotated and only if it will be rotated.

Default value: undef

firstaction

Data type: Optional[String]

A command String or an Array of Strings that should be executed by /bin/sh once before all log files that match the wildcard pattern are rotated.

Default value: undef

lastaction

Data type: Optional[String]

A command String or an Array of Strings that should be executed by /bin/sh once after all the log files that match the wildcard pattern are rotated.

Default value: undef

rotate

Data type: Integer

The Integer number of rotated log files to keep on disk.

Default value: 4

rotate_every

Data type: Logrotate::Every

How often the log files should be rotated as a String. Valid values are 'day', 'week', 'month' and 'year'.

Default value: 'weekly'

size

Data type: Optional[Logrotate::Size]

The String size a log file has to reach before it will be rotated. The default units are bytes, append k, M or G for kilobytes, megabytes or gigabytes respectively.

Default value: undef

sharedscripts

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should run the postrotate and prerotate scripts for each matching file or just once.

Default value: undef

shred

Data type: Optional[Boolean]

A Boolean specifying whether logs should be deleted with shred instead of unlink.

Default value: undef

shredcycles

Data type: Optional[Integer]

The Integer number of times shred should overwrite log files before unlinking them.

Default value: undef

start

Data type: Optional[Integer]

The Integer number to be used as the base for the extensions appended to the rotated log files.

Default value: undef

su

Data type: Boolean

A Boolean specifying whether logrotate should rotate under the specific su_user and su_group instead of the default. First available in logrotate 3.8.0.

Default value: false

su_user

Data type: String

A String username that logrotate should use to rotate a log file set instead of using the default if su => true.

Default value: 'root'

su_group

Data type: String

A String group name that logrotate should use to rotate a log file set instead of using the default if su => true.

Default value: 'root'

tabooext

Data type: Optional[Variant[String,Array[String[1]]]]

Ignore files whose names end with one of the taboo extensions If a + precedes the list of extensions, the current taboo extension list is augmented, otherwise it is replaced.

Default value: undef

taboopat

Data type: Optional[Variant[String,Array[String[1]]]]

Ignore files whose names end with one of the taboo patterns If a + precedes the list of patterns, the current taboo pattern list is augmented, otherwise it is replaced.

Default value: undef

uncompresscmd

Data type: Optional[String]

The String command to be used to uncompress log files.

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

include

Data type: Optional[Variant[String,Array[String[1]]]]

Default value: undef

logrotate::cron

Manage logrotate cron entries

Parameters

The following parameters are available in the logrotate::cron defined type:

ensure

Data type: Any

Default value: 'present'

logrotate::rule

Configure logrotate to rotate a logfile.

Examples

Rotate /var/log/syslog daily and keep 7 days worth of compressed logs.
logrotate::rule { 'messages':
  path         => '/var/log/messages',
  copytruncate => true,
  missingok    => true,
  rotate_every => 'day',
  rotate       => 7,
  compress     => true,
  ifempty      => true,
}
Rotate /var/log/nginx/access_log weekly and keep 3 weeks of logs
logrotate::rule { 'nginx_access_log':
  path         => '/var/log/nginx/access_log',
  missingok    => true,
  rotate_every => 'week',
  rotate       => 3,
  postrotate   => '/etc/init.d/nginx restart',
}

Parameters

The following parameters are available in the logrotate::rule defined type:

rulename

Data type: Pattern[/^[a-zA-Z0-9\._-]+$/]

The String name of the rule.

Default value: $title

path

Data type: Optional[Logrotate::Path]

The path String to the logfile(s) to be rotated.

Default value: undef

ensure

Data type: Enum['present','absent']

The desired state of the logrotate rule as a String. Valid values are 'absent' and 'present' (default: 'present').

Default value: 'present'

compress

Data type: Optional[Boolean]

A Boolean value specifying whether the rotated logs should be compressed.

Default value: undef

compresscmd

Data type: Optional[String]

The command String that should be executed to compress the rotated logs.

Default value: undef

compressext

Data type: Optional[String]

The extention String to be appended to the rotated log files after they have been compressed.

Default value: undef

compressoptions

Data type: Optional[String]

A String of command line options to be passed to the compression program specified in compresscmd.

Default value: undef

copy

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should just take a copy of the log file and not touch the original.

Default value: undef

copytruncate

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should truncate the original log file after taking a copy.

Default value: undef

create

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should create a new log file immediately after rotation.

Default value: undef

create_mode

Data type: Optional[String]

An octal mode String logrotate should apply to the newly created log file if create => true.

Default value: undef

create_owner

Data type: Optional[String]

A username String that logrotate should set the owner of the newly created log file to if create => true.

Default value: undef

create_group

Data type: Optional[String]

A String group name that logrotate should apply to the newly created log file if create => true.

Default value: undef

dateext

Data type: Optional[Boolean]

A Boolean specifying whether rotated log files should be archived by adding a date extension rather just a number.

Default value: undef

dateformat

Data type: Optional[String]

The format String to be used for dateext . Valid specifiers are '%Y', '%m', '%d' and '%s'.

Default value: undef

dateyesterday

Data type: Optional[Boolean]

A Boolean specifying whether to use yesterday's date instead of today's date to create the dateext extension.

Default value: undef

delaycompress

Data type: Optional[Boolean]

A Boolean specifying whether compression of the rotated log file should be delayed until the next logrotate run.

Default value: undef

extension

Data type: Optional[String]

Log files with this extension String are allowed to keep it after rotation.

Default value: undef

ifempty

Data type: Optional[Boolean]

A Boolean specifying whether the log file should be rotated even if it is empty.

Default value: undef

mail

Data type: Optional[Variant[String,Boolean]]

The email address String that logs that are about to be rotated out of existence are emailed to.

Default value: undef

mail_when

Data type: Optional[Enum['mailfirst','maillast']]

When mail is configured, enable mailfirst (email the just rotated file rather than the about to expire file) and/or maillast (email the about to expire file rather than the just rotated file) behaviours.

Default value: undef

maxage

Data type: Optional[Integer]

The Integer maximum number of days that a rotated log file can stay on the system.

Default value: undef

minsize

Data type: Optional[Logrotate::Size]

The String minimum size a log file must be to be rotated, but not before the scheduled rotation time. The default units are bytes, append k, M or G for kilobytes, megabytes and gigabytes respectively.

Default value: undef

maxsize

Data type: Optional[Logrotate::Size]

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.

Default value: undef

missingok

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should ignore missing log files or issue an error.

Default value: undef

olddir

Data type: Optional[Variant[Boolean,String]]

A String path to a directory that rotated logs should be moved to.

Default value: undef

postrotate

Data type: Optional[Logrotate::Commands]

A command String or an Array of Strings that should be executed by /bin/sh after the log file is rotated optional).

Default value: undef

prerotate

Data type: Optional[Logrotate::Commands]

A command String or an Array of Strings that should be executed by /bin/sh before the log file is rotated and only if it will be rotated.

Default value: undef

firstaction

Data type: Optional[Logrotate::Commands]

A command String or an Array of Strings that should be executed by /bin/sh once before all log files that match the wildcard pattern are rotated.

Default value: undef

lastaction

Data type: Optional[Logrotate::Commands]

A command String or an Array of Strings that should be executed by /bin/sh once after all the log files that match the wildcard pattern are rotated.

Default value: undef

rotate

Data type: Optional[Integer]

The Integer number of rotated log files to keep on disk.

Default value: undef

rotate_every

Data type: Optional[Logrotate::Every]

How often the log files should be rotated as a String. Valid values are 'day', 'week', 'month' and 'year'.

Default value: undef

size

Data type: Optional[Logrotate::Size]

The String size a log file has to reach before it will be rotated. The default units are bytes, append k, M or G for kilobytes, megabytes or gigabytes respectively.

Default value: undef

sharedscripts

Data type: Optional[Boolean]

A Boolean specifying whether logrotate should run the postrotate and prerotate scripts for each matching file or just once.

Default value: undef

shred

Data type: Optional[Boolean]

A Boolean specifying whether logs should be deleted with shred instead of unlink.

Default value: undef

shredcycles

Data type: Optional[Integer]

The Integer number of times shred should overwrite log files before unlinking them.

Default value: undef

start

Data type: Optional[Integer]

The Integer number to be used as the base for the extensions appended to the rotated log files.

Default value: undef

su

Data type: Boolean

A Boolean specifying whether logrotate should rotate under the specific su_user and su_group instead of the default. First available in logrotate 3.8.0.

Default value: false

su_user

Data type: String

A String username that logrotate should use to rotate a log file set instead of using the default if su => true.

Default value: 'root'

su_group

Data type: String

A String group name that logrotate should use to rotate a log file set instead of using the default if su => true.

Default value: 'root'

uncompresscmd

Data type: Optional[String]

The String command to be used to uncompress log files.

Default value: undef

custom_cfg

Data type: Array[String[1]]

Array of custom lines to be appended to the rules.

Default value: []

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

Data types

Logrotate::Commands

Data type for commands

Alias of Variant[String, Array[String]]

Logrotate::Every

Valid configuration values for rotation (every hour/day/week/month etc.)

Alias of Pattern['^hour(|ly)$', '^da(|il)y$', '^week(|ly)( [0-7])?$', '^month(|ly)$', '^year(|ly)$']

Logrotate::Path

File path valid in logrotate config files

Alias of Variant[Stdlib::UnixPath, Array[Stdlib::UnixPath]]

Logrotate::Size

Filesize valid in logrotate config files

Alias of Variant[Integer, Pattern[/^\d+[kMG]?$/]]