Defined Type: rsyslog::template::subtree

Defined in:
manifests/template/subtree.pp

Overview

Add template subtrees to the rsyslog configuration

You'll need to write the entire subtree line due to the complexity of the rsyslog configuration parameters.

Examples:

Subtree (From the Official RSyslog Docs)

rsyslog::template::subtree { 'example_subtree':
  $variables => ['$!usr!tp12!msg = $msg;', '$!usr!tp12!dataflow = field($msg, 58, 2);'],
  $subtree   => '$!usr!tp12'
}

### Produces:

set $!usr!tp12!msg = $msg;
set $!usr!tp12!dataflow = field($msg, 58, 2);
template(name="example" type="subtree" subtree="$!usr!tp12")

Parameters:

  • name (String)

    The literal name of the file (not a path) that will be used

  • subtree (String)

    The rsyslog subtree content that you wish to add to the system

    • This is fed, without formatting, directly into the subtree parameter

  • variables (Array[String]) (defaults to: [])

    Variables to be set prior to the template being created



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'manifests/template/subtree.pp', line 29

define rsyslog::template::subtree (
  String        $subtree,
  Array[String] $variables = []
) {
  $_safe_name = regsubst($name,'/','__')

  $_variables = join($variables,"\n")

  rsyslog::rule { "05_simp_templates/${_safe_name}.conf":
    # lint:ignore:variables_not_enclosed
    content => @("EOM")
      $_variables

      template(name="${name}" type="subtree" subtree="${subtree}")
      |EOM
    # lint:endignore
  }
}