Skip to content

Latest commit

 

History

History
1314 lines (665 loc) · 30.1 KB

REFERENCE.md

File metadata and controls

1314 lines (665 loc) · 30.1 KB

Reference

Table of Contents

Classes

Defined types

  • logrotate::conf: Internal: Install and configure logrotate defaults file, usually /etc/logrotate.conf see logrotate::Conf for description of options. Exam
  • logrotate::cron
  • logrotate::rule: Public: Configure logrotate to rotate a logfile. namevar - The String name of the rule. path - The path String to the log

Data types

Classes

logrotate

The logrotate class.

Parameters

The following parameters are available in the logrotate class:

ensure

Data type: String

Default value: present

hieramerge

Data type: Boolean

Default value: false

manage_cron_daily

Data type: Boolean

Default value: true

manage_cron_hourly

Data type: Boolean

Default value: true

ensure_cron_daily

Data type: Enum[present,absent]

Default value: 'present'

ensure_cron_hourly

Data type: Enum[present,absent]

Default value: 'present'

manage_systemd_timer

Data type: Boolean

Default value: false

ensure_systemd_timer

Data type: Enum[present,absent]

Default value: 'absent'

create_base_rules

Data type: Boolean

Default value: true

purge_configdir

Data type: Boolean

Default value: false

package

Data type: String

Default value: 'logrotate'

rules

Data type: Hash

Default value: {}

config

Data type: Optional[Hash]

Default value: undef

cron_daily_hour

Data type: Integer[0,23]

Default value: $logrotate::params::cron_daily_hour

cron_daily_minute

Data type: Integer[0,59]

Default value: $logrotate::params::cron_daily_minute

cron_hourly_minute

Data type: Integer[0,59]

Default value: $logrotate::params::cron_hourly_minute

cron_file_mode

Data type: Stdlib::Filemode

Default value: $logrotate::params::cron_file_mode

configdir

Data type: String

Default value: $logrotate::params::configdir

logrotate_bin

Data type: String

Default value: $logrotate::params::logrotate_bin

logrotate_conf

Data type: String

Default value: $logrotate::params::logrotate_conf

logrotate_conf_mode

Data type: Stdlib::Filemode

Default value: $logrotate::params::logrotate_conf_mode

manage_package

Data type: Boolean

Default value: $logrotate::params::manage_package

rules_configdir

Data type: String

Default value: $logrotate::params::rules_configdir

rules_configdir_mode

Data type: Stdlib::Filemode

Default value: $logrotate::params::rules_configdir_mode

root_user

Data type: String

Default value: $logrotate::params::root_user

root_group

Data type: String

Default value: $logrotate::params::root_group

logrotate_args

Data type: Array[String[1]]

Default value: []

cron_always_output

Data type: Boolean

Default value: false

logrotate::config

logrotate config

logrotate::defaults

apply defaults

Parameters

The following parameters are available in the logrotate::defaults class:

create_base_rules

Data type: Any

Default value: $logrotate::create_base_rules

rules

Data type: Any

Default value: $logrotate::params::base_rules

rule_default

Data type: Any

Default value: $logrotate::params::rule_default

logrotate::hourly

Internal: Configure a host for hourly logrotate jobs.

ensure - The desired state of hourly logrotate support. Valid values are 'absent' and 'present' (default: 'present').

Examples

Set up hourly logrotate jobs

class { 'logrotate': manage_cron_hourly => true, }

Remove hourly logrotate job support

class { 'logrotate': manage_cron_hourly => true, ensure_cron_hourly => absent, }

logrotate::install

make sure logrotate is installed

logrotate::params

== Class: logrotate::params

Params class for logrotate module

logrotate::rules

apply user-defined rules

Parameters

The following parameters are available in the logrotate::rules class:

rules

Data type: Any

Default value: $logrotate::rules

Defined types

logrotate::conf

Internal: Install and configure logrotate defaults file, usually /etc/logrotate.conf

see logrotate::Conf for description of options.

Examples

logrotate::conf{'/etc/logrotate.conf':}

Parameters

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

path

Data type: Stdlib::Unixpath

Default value: $name

ensure

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

Default value: 'present'

compress

Data type: Optional[Boolean]

Default value: undef

compresscmd

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: Boolean

Default value: true

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

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

ifempty

Data type: Optional[Boolean]

Default value: undef

mail

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

Default value: undef

mail_when

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

Default value: undef

maxage

Data type: Optional[Integer]

Default value: undef

minsize

Data type: Optional[Logrotate::Size]

Default value: undef

maxsize

Data type: Optional[Logrotate::Size]

Default value: undef

missingok

Data type: Optional[Boolean]

Default value: undef

olddir

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

Default value: undef

postrotate

Data type: Optional[String]

Default value: undef

prerotate

Data type: Optional[String]

Default value: undef

firstaction

Data type: Optional[String]

Default value: undef

lastaction

Data type: Optional[String]

Default value: undef

rotate

Data type: Integer

Default value: 4

rotate_every

Data type: Logrotate::Every

Default value: 'weekly'

size

Data type: Optional[Logrotate::Size]

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: Boolean

Default value: false

su_user

Data type: String

Default value: 'root'

su_group

Data type: String

Default value: 'root'

uncompresscmd

Data type: Optional[String]

Default value: undef

logrotate::cron

The logrotate::cron class.

Parameters

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

ensure

Data type: Any

Default value: 'present'

logrotate::rule

Public: Configure logrotate to rotate a logfile.

namevar - The String name of the rule. path - The path String to the logfile(s) to be rotated. 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 or an Array of Strings that should be executed by /bin/sh after the log file is rotated optional). prerotate - 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 (optional). firstaction - 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 (optional). lastaction - 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 (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 'day', 'week', 'month' and 'year' (optional). 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 - 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. su_user - A String username 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). custom_cfg - Array of custom lines to be appended to the rules

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\._-]+$/]

Default value: $title

ensure

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

Default value: 'present'

custom_cfg

Data type: Array[String[1]]

Default value: []

path

Data type: Optional[Logrotate::Path]

Default value: undef

compress

Data type: Optional[Boolean]

Default value: undef

compresscmd

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

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

ifempty

Data type: Optional[Boolean]

Default value: undef

mail

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

Default value: undef

mail_when

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

Default value: undef

maxage

Data type: Optional[Integer]

Default value: undef

minsize

Data type: Optional[Logrotate::Size]

Default value: undef

maxsize

Data type: Optional[Logrotate::Size]

Default value: undef

missingok

Data type: Optional[Boolean]

Default value: undef

olddir

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

Default value: undef

postrotate

Data type: Optional[Logrotate::Commands]

Default value: undef

prerotate

Data type: Optional[Logrotate::Commands]

Default value: undef

firstaction

Data type: Optional[Logrotate::Commands]

Default value: undef

lastaction

Data type: Optional[Logrotate::Commands]

Default value: undef

rotate

Data type: Optional[Integer]

Default value: undef

rotate_every

Data type: Optional[Logrotate::Every]

Default value: undef

size

Data type: Optional[Logrotate::Size]

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: Boolean

Default value: false

su_user

Data type: String

Default value: 'root'

su_group

Data type: String

Default value: 'root'

uncompresscmd

Data type: Optional[String]

Default value: undef

Data types

Logrotate::Commands

The Logrotate::Commands data type.

Alias of Variant[String, Array[String]]

Logrotate::Every

The Logrotate::Every data type.

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

Logrotate::Path

The Logrotate::Path data type.

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

Logrotate::Size

The Logrotate::Size data type.

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