Puppet Class: logrotate

Defined in:
manifests/init.pp

Overview

Configure LogRotate global options

Use logrotate::rule for specific configuration options.

Parameters:

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

    How often to rotate the logs

  • rotate (Integer[0]) (defaults to: 4)

    The number of times to rotate the logs before removing them from the system

  • create (Boolean) (defaults to: true)

    Create new log files if they do not exist

  • compress (Boolean) (defaults to: true)

    Compress the logs upon rotation

  • include_dirs (Array[Stdlib::Absolutepath]) (defaults to: [])

    Directories to include in your logrotate configuration

    • /etc/logrotate.d is always included

  • manage_wtmp (Boolean) (defaults to: true)

    Set to false if you do not want /var/log/wtmp to be managed by logrotate

  • dateext (Boolean) (defaults to: true)

    Use dateext as the suffix for rotated files

  • dateformat (String) (defaults to: '-%Y%m%d.%s')

    The format of the date to be appended

    • Leaving as is allows for multiple rotations per day

  • maxsize (Optional[Pattern['^\d+(k|M|G)?$']]) (defaults to: undef)

    The default maximum size of a logfile

  • minsize (Optional[Pattern['^\d+(k|M|G)?$']]) (defaults to: undef)

    The default minimum size of a logfile

    • Overrides the maxsize setting

Author:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'manifests/init.pp', line 45

class logrotate (
  Enum['daily','weekly','monthly','yearly'] $rotate_period = 'weekly',
  Integer[0]                                $rotate        = 4,
  Boolean                                   $create        = true,
  Boolean                                   $compress      = true,
  Array[Stdlib::Absolutepath]               $include_dirs  = [],
  Boolean                                   $manage_wtmp   = true,
  Boolean                                   $dateext       = true,
  String                                    $dateformat    = '-%Y%m%d.%s',
  Optional[Pattern['^\d+(k|M|G)?$']]        $maxsize       = undef,
  Optional[Pattern['^\d+(k|M|G)?$']]        $minsize       = undef
) {
  package { 'logrotate': ensure => 'latest' }

  file { '/etc/logrotate.conf':
    ensure  => 'file',
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => template("${module_name}/logrotate.conf.erb")
  }

  file { '/etc/logrotate.d':
    ensure => 'directory',
    owner  => 'root',
    group  => 'root',
    mode   => '0644'
  }
}