Defined Type: logrotate::rule

Defined in:
modules/logrotate/manifests/rule.pp

Overview

Define logrotate::rule

Provides a common template that can be used by different applications to configure log rotation. See logrotate man page for detailed documentation.

Most parameters of this class map directly to the corresponding logrotate options.

frequency

frequency of log rotation, must be in [ 'daily', 'weekly', 'monthly', 'yearly' ]. default: undef

size

Size after which to rotate, or maxsize if frequency is defined. default: undef

Parameters:

  • file_glob (String)
  • ensure (Wmflib::Ensure) (defaults to: present)
  • frequency (Optional[Enum['daily', 'weekly', 'monthly', 'yearly']]) (defaults to: undef)
  • not_if_empty (Boolean) (defaults to: false)
  • date_yesterday (Boolean) (defaults to: false)
  • copy_truncate (Boolean) (defaults to: false)
  • max_age (Optional[Integer]) (defaults to: undef)
  • rotate (Optional[Integer]) (defaults to: undef)
  • date_ext (Boolean) (defaults to: false)
  • compress (Boolean) (defaults to: false)
  • missing_ok (Boolean) (defaults to: false)
  • size (Optional[String]) (defaults to: undef)
  • no_create (Boolean) (defaults to: false)
  • post_rotate (Optional[String]) (defaults to: undef)
  • su (Optional[String]) (defaults to: undef)
  • create (Optional[String]) (defaults to: undef)
  • old_dir (Optional[String]) (defaults to: undef)


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
# File 'modules/logrotate/manifests/rule.pp', line 17

define logrotate::rule (
    String $file_glob,
    Wmflib::Ensure $ensure = present,
    Optional[Enum['daily', 'weekly', 'monthly', 'yearly']] $frequency = undef,
    Boolean $not_if_empty = false,
    Boolean $date_yesterday = false,
    Boolean $copy_truncate = false,
    Optional[Integer] $max_age = undef,
    Optional[Integer] $rotate = undef,
    Boolean $date_ext = false,
    Boolean $compress = false,
    Boolean $missing_ok = false,
    Optional[String] $size = undef,
    Boolean $no_create = false,
    Optional[String] $post_rotate = undef,
    Optional[String] $su = undef,
    Optional[String] $create = undef,
    Optional[String] $old_dir = undef,
) {

    $actual_size = $size ? {
        undef => undef,
        default => $frequency ? {
            undef   => "size ${size}",
            default => "maxsize ${size}",
        }
    }

    logrotate::conf { $title:
        ensure  => $ensure,
        content => template('logrotate/logrotate.erb'),
    }
}