Defined Type: logrotate::conf

Defined in:
manifests/conf.pp

Overview

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:

  • path (Stdlib::Unixpath) (defaults to: $name)
  • ensure (Enum['absent','present']) (defaults to: 'present')
  • compress (Optional[Boolean]) (defaults to: undef)
  • compresscmd (Optional[String]) (defaults to: undef)
  • compressext (Optional[String]) (defaults to: undef)
  • compressoptions (Optional[String]) (defaults to: undef)
  • copy (Optional[Boolean]) (defaults to: undef)
  • copytruncate (Optional[Boolean]) (defaults to: undef)
  • create (Boolean) (defaults to: true)
  • create_mode (Optional[String]) (defaults to: undef)
  • create_owner (Optional[String]) (defaults to: undef)
  • create_group (Optional[String]) (defaults to: undef)
  • dateext (Optional[Boolean]) (defaults to: undef)
  • dateformat (Optional[String]) (defaults to: undef)
  • dateyesterday (Optional[Boolean]) (defaults to: undef)
  • delaycompress (Optional[Boolean]) (defaults to: undef)
  • extension (Optional[String]) (defaults to: undef)
  • ifempty (Optional[Boolean]) (defaults to: undef)
  • mail (Optional[Variant[String,Boolean]]) (defaults to: undef)
  • mail_when (Optional[Enum['mailfirst', 'maillast']]) (defaults to: undef)
  • maxage (Optional[Integer]) (defaults to: undef)
  • minsize (Optional[Logrotate::Size]) (defaults to: undef)
  • maxsize (Optional[Logrotate::Size]) (defaults to: undef)
  • missingok (Optional[Boolean]) (defaults to: undef)
  • olddir (Optional[Variant[Boolean,String]]) (defaults to: undef)
  • postrotate (Optional[String]) (defaults to: undef)
  • prerotate (Optional[String]) (defaults to: undef)
  • firstaction (Optional[String]) (defaults to: undef)
  • lastaction (Optional[String]) (defaults to: undef)
  • rotate (Integer) (defaults to: 4)
  • rotate_every (Logrotate::Every) (defaults to: 'weekly')
  • size (Optional[Logrotate::Size]) (defaults to: undef)
  • sharedscripts (Optional[Boolean]) (defaults to: undef)
  • shred (Optional[Boolean]) (defaults to: undef)
  • shredcycles (Optional[Integer]) (defaults to: undef)
  • start (Optional[Integer]) (defaults to: undef)
  • su (Boolean) (defaults to: false)
  • su_user (String) (defaults to: 'root')
  • su_group (String) (defaults to: 'root')
  • uncompresscmd (Optional[String]) (defaults to: undef)


10
11
12
13
14
15
16
17
18
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'manifests/conf.pp', line 10

define logrotate::conf (
  Stdlib::Unixpath $path                             = $name,
  Enum['absent','present'] $ensure                   = 'present',
  Optional[Boolean] $compress                        = undef,
  Optional[String] $compresscmd                      = undef,
  Optional[String] $compressext                      = undef,
  Optional[String] $compressoptions                  = undef,
  Optional[Boolean] $copy                            = undef,
  Optional[Boolean] $copytruncate                    = undef,
  Boolean $create                                    = true,
  Optional[String] $create_mode                      = undef,
  Optional[String] $create_owner                     = undef,
  Optional[String] $create_group                     = undef,
  Optional[Boolean] $dateext                         = undef,
  Optional[String] $dateformat                       = undef,
  Optional[Boolean] $dateyesterday                   = undef,
  Optional[Boolean] $delaycompress                   = undef,
  Optional[String] $extension                        = undef,
  Optional[Boolean] $ifempty                         = undef,
  Optional[Variant[String,Boolean]] $mail            = undef,
  Optional[Enum['mailfirst', 'maillast']] $mail_when = undef,
  Optional[Integer] $maxage                          = undef,
  Optional[Logrotate::Size] $minsize                 = undef,
  Optional[Logrotate::Size] $maxsize                 = undef,
  Optional[Boolean] $missingok                       = undef,
  Optional[Variant[Boolean,String]] $olddir          = undef,
  Optional[String] $postrotate                       = undef,
  Optional[String] $prerotate                        = undef,
  Optional[String] $firstaction                      = undef,
  Optional[String] $lastaction                       = undef,
  Integer $rotate                                    = 4,
  Logrotate::Every $rotate_every                     = 'weekly',
  Optional[Logrotate::Size] $size                    = undef,
  Optional[Boolean] $sharedscripts                   = undef,
  Optional[Boolean] $shred                           = undef,
  Optional[Integer] $shredcycles                     = undef,
  Optional[Integer] $start                           = undef,
  Boolean $su                                        = false,
  String $su_user                                    = 'root',
  String $su_group                                   = 'root',
  Optional[String] $uncompresscmd                    = undef
) {
  case $mail {
    /\w+/: { $_mail = "mail ${mail}" }
    false: { $_mail = 'nomail' }
    default: {}
  }

  case $olddir {
    /\w+/: { $_olddir = "olddir ${olddir}" }
    false: { $_olddir = 'noolddir' }
    default: {}
  }

  if $rotate_every {
    $_rotate_every = $rotate_every ? {
      /ly$/   => $rotate_every,
      'day'   => 'daily',
      default => "${rotate_every}ly"
    }
  }

  if $create_group and !$create_owner {
    fail("Logrotate::Conf[${name}]: create_group requires create_owner")
  }

  if $create_owner and !$create_mode {
    fail("Logrotate::Conf[${name}]: create_owner requires create_mode")
  }

  if $create_mode and !$create {
    fail("Logrotate::Conf[${name}]: create_mode requires create")
  }

  #
  ####################################################################

  include logrotate

  $rules_configdir = $logrotate::rules_configdir

  file { $path:
    ensure  => $ensure,
    owner   => $logrotate::root_user,
    group   => $logrotate::root_group,
    mode    => $logrotate::logrotate_conf_mode,
    content => template('logrotate/etc/logrotate.conf.erb'),
  }

  if $logrotate::manage_package {
    Package[$logrotate::package] -> File[$path]
  }
}