Puppet Class: rsyslog::config::logrotate

Defined in:
manifests/config/logrotate.pp

Overview

NOTE: THIS IS A PRIVATE CLASS

Default log rotation for RSyslog

The list that is managed here matches the list of default files that are managed on the system by this module.

Parameters:

  • rotate_period (Enum['daily','weekly','monthly','yearly']) (defaults to: 'daily')

    How often to rotate the logs

  • rotate_preserve (Stdlib::Compat::Integer) (defaults to: '7')

    How many rotated logs to keep

  • rotate_size (Optional[Stdlib::Compat::Integer]) (defaults to: undef)

    The maximum size of a log file

    • $rotate_period will be ignored if this is specified



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'manifests/config/logrotate.pp', line 19

class rsyslog::config::logrotate (
  Enum['daily','weekly','monthly','yearly'] $rotate_period   = 'daily',
  Stdlib::Compat::Integer                   $rotate_preserve = '7',
  Optional[Stdlib::Compat::Integer]         $rotate_size     = undef
){
  assert_private()

  include '::logrotate'

  $_restartcmd = 'systemd' in $facts['init_systems'] ? {
    true    => '/usr/sbin/systemctl restart rsyslog',
    default => '/usr/sbin/service rsyslog restart'
  }

  logrotate::add { 'syslog':
    log_files     => [
      '/var/log/boot.log',
      '/var/log/cron',
      '/var/log/iptables.log',
      '/var/log/maillog',
      '/var/log/messages',
      '/var/log/puppet*.log',
      '/var/log/secure',
      '/var/log/slapd*.log',
      '/var/log/spooler'
    ],
    size          => $rotate_size,
    rotate_period => $rotate_period,
    rotate        => $rotate_preserve,
    lastaction    => "${_restartcmd} > /dev/null 2>&1 || true",
    missingok     => true
  }
}