Defined Type: rsyslog::conf

Defined in:
puppet/modules/rsyslog/manifests/conf.pp

Overview

Define: rsyslog::conf

Represents an rsyslogd config file. See rsyslog.conf(5).

Parameters

content

The content of the file provided as a string. Either this or 'source' must be specified.

source

The content of the file provided as a puppet:/// file reference. Either this or 'content' must be specified.

priority

A numeric value in range 0 - 99. Files with a lower priority value are evaluated first.

If you're not sure, leave this unspecified. The default value of 60 should suit most cases.

Examples

rsyslog::conf { 'hadoop':
  content  => template('hadoop/hadoop.conf.erb'),
  priority => 90,
}

Parameters:

  • ensure (Any) (defaults to: present)
  • content (Any) (defaults to: undef)
  • source (Any) (defaults to: undef)
  • priority (Any) (defaults to: 60)


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
# File 'puppet/modules/rsyslog/manifests/conf.pp', line 29

define rsyslog::conf(
    $ensure   = present,
    $content  = undef,
    $source   = undef,
    $priority = 60
) {
    include ::rsyslog

    if $priority !~ Integer[0, 99] {
        fail("'priority' must be an integer between 0 - 99 (got: ${priority}).")
    }

    $basename = regsubst($title, '[\W_]', '-', 'G')
    $filename = sprintf('/etc/rsyslog.d/%02d-%s.conf', $priority, $basename)

    # append a trailing newline if omitted
    $content_formatted = $content ? {
        undef   => undef,
        default => regsubst($content, "\n?$", "\n")
    }

    file { $filename:
        ensure  => $ensure,
        content => $content_formatted,
        source  => $source,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        notify  => Service['rsyslog'],
    }
}