Skip to content

Latest commit

 

History

History
581 lines (368 loc) · 14 KB

REFERENCE.md

File metadata and controls

581 lines (368 loc) · 14 KB

Reference

Table of Contents

Classes

Public Classes

Private Classes

  • syslog_ng::reload: Manage syslog-ng configuration reloading
  • syslog_ng::repo: Manage the syslog-ng repository

Defined types

Functions

Classes

syslog_ng

The main class of this module. By including it you get an installed syslog-ng with default configuration on your system.

Parameters

The following parameters are available in the syslog_ng class:

config_file

Data type: Stdlib::Absolutepath

Configures the path of the configuration file.

package_name

Data type: String[1]

Name of the package to manage when manage_package is true.

service_name

Data type: String[1]

Name of the syslog-ng service.

module_prefix

Data type: String[1]

A string to prepend to syslog-ng module names to obtain the corresponding package names.

config_file_header

Data type: String[1]

A header string that appear on top of the syslog-ng configuration.

package_ensure

Data type: String[1]

The value of the ensure parameter of package resources.

manage_repo

Data type: Boolean

Controls if the module is managing the unofficial repositories of syslog-ng packages. Use true if you want to use the latest version of syslog-ng from the unofficial Debian repository or unofficial RedHat repository.

Default value: false

manage_package

Data type: Boolean

Controls if the module is managing the package resource or not. Use false if you are already handling this in your manifests.

Default value: true

manage_init_defaults

Data type: Boolean

Controls if the module is managing the init script's config file (See init_config_file and init_config_hash).

Default value: false

modules

Data type: Array[String[1]]

Configures additional syslog-ng modules. If manage_package is set to true this will also install the corresponding packages, e.g. syslog-ng-riemann on RedHat if modules = ['riemann'].

Default value: []

sbin_path

Data type: Stdlib::Absolutepath

Configures the path, where syslog-ng and syslog-ng-ctl binaries can be found.

Default value: '/usr/sbin'

user

Data type: String[1]

Configures syslog-ng to run as user.

Default value: 'root'

group

Data type: String[1]

Configures syslog-ng to run as group.

Default value: 'root'

syntax_check_before_reloads

Data type: Boolean

The module always checks the syntax of the generated configuration. If it is not OK, the main configuration (usually /etc/syslog-ng/syslog-ng.conf) will not be overwritten, but you can disable this behavior by setting this parameter to false.

Default value: true

init_config_file

Data type: Stdlib::Absolutepath

Path to the init script configuration file.

init_config_hash

Data type: Hash

Hash of init configuration options to put into init_config_file. This has OS specific defaults which will be merged to user specified value.

Defined types

syslog_ng::config

Some elements of the syslog-ng DSL are not supported by this module (mostly the boolean operators in filters) so you may want to keep some configuration snippets in their original form. This type lets you write texts into the configuration without any parsing or processing.

Every configuration file begins with a @version: line. You can use this type to write this line into the configuration, make comments or use existing snippets.

syslog_ng::config {'version':
   content => '@version: 3.6',
   order => '02'
}

Parameters

The following parameters are available in the syslog_ng::config defined type:

content

Data type: String[1]

Configures the text which must be written into the configuration file. A newline character is automatically appended to its end.

order

Data type: String[1]

Sets the order of this snippet in the configuration file. If you want to write the version line, the order => '02' is suggested, because the auto generated header has order '01'.

Default value: '5'

syslog_ng::destination

Creates a destination in your configuration.

syslog_ng::destination { 'd_udp':
  params => {
    'type' => 'udp',
    'options' => [
      "'127.0.0.1'",
      { 'port' => '1999' },
      { 'localport' => '999' },
    ],
  },
}

#### Parameters

The following parameters are available in the `syslog_ng::destination` defined type:

* [`params`](#-syslog_ng--destination--params)

##### <a name="-syslog_ng--destination--params"></a>`params`

Data type: `Data`

An array of hashes or a single hash.

Default value: `[]`

### <a name="syslog_ng--filter"></a>`syslog_ng::filter`

Creates a filter in your configuration. **It does not support binary operators, such as `and` or `or`**. Please, use a `syslog_ng::config` if you need this functionality.

```puppet
syslog_ng::filter { 'f_tag_filter':
  params => {
    'type' => 'tags',
    'options' => [
      '".classifier.system"',
    ],
  },
}

Parameters

The following parameters are available in the syslog_ng::filter defined type:

params

Data type: Data

An array of hashes or a single hash.

Default value: []

syslog_ng::log

Creates log paths in your configuration. It can create channels, junctions and reference already defined sources, destinations, etc. The syntax is a little bit different then the one previously described under statements.

Here is a simple rule: if you want to reference an already defined type (e.g. s_gsoc2014) use a hash with one key-value pair. The key must be the type of the statement (e.g. source) and the value must be its title.

If you do not specify a reference, use an array instead. Take a look at the example below:

syslog_ng::log { 'l2':
  params => [
    { 'source' => 's_gsoc2014' },
    {
      'junction' => [
        {
          'channel' => [
            { 'filter' => 'f_json' },
            { 'parser' => 'p_json' },
          ],
        },
        {
          'channel' => [
            { 'filter' => 'f_not_json' },
            { 'flags' => 'final' },
          ],
        },
      ],
    },
    { 'destination' => 'd_gsoc' },
  ],
}

Parameters

The following parameters are available in the syslog_ng::log defined type:

params

Data type: Data

The syntax is a bit different, but you can find examples under the tests directory.

Default value: []

syslog_ng::module

Install syslog-ng modules

syslog_ng::options

Creates a global options statement. Currently it is not a class, so you should not declare it multiple times! It is not defined as a class, so you can declare it as other similar types.

syslog_ng::options { "global_options":
  options => {
    'bad_hostname' => "'no'",
    'time_reopen'  => 10,
  },
}

Parameters

The following parameters are available in the syslog_ng::options defined type:

options

Data type: Hash

A hash containing string keys and string values. In the generated configuration the keys will appear in alphabetical order.

Default value: {}

syslog_ng::parser

Creates a parser statement in your configuration.

syslog_ng::parser { 'p_hostname_segmentation':
  params => {
    'type' => 'csv-parser',
    'options' => [
      {
        'columns' => [
          '"HOSTNAME.NAME"',
          '"HOSTNAME.ID"',
        ],
      },
      {'delimiters' => '"-"'},
      {'flags' => 'escape-none'},
      {'template' => '"${HOST}"'},
    ],
  },
}

Parameters

The following parameters are available in the syslog_ng::parser defined type:

params

Data type: Data

An array of hashes or a single hash.

Default value: []

syslog_ng::rewrite

Creates one or more rewrite rules in your configuration.

syslog_ng::rewrite{ 'r_rewrite_subst':
  params => {
    'type' => 'subst',
    'options' => [
      '"IP"',
      '"IP-Address"',
      { 'value' => '"MESSAGE"' },
      { 'flags' => 'global' },
    ],
  },
}

Parameters

The following parameters are available in the syslog_ng::rewrite defined type:

params

Data type: Data

An array of hashes or a single hash.

Default value: []

syslog_ng::source

Creates a source in your configuration.

syslog_ng::source { 's_gsoc':
  params => {
    'type'    => 'tcp',
    'options' => [
      { 'ip' => "'127.0.0.1'" },
      { 'port' => 1999 },
    ],
  },
}

syslog_ng::source { 's_external':
  params => [
    {
      'type'    => 'udp',
      'options' => [
        { 'ip' => ["'127.0.0.1'"] },
        { 'port' => [514] },
      ],
    },
    {
      'type'    => 'tcp',
      'options' => [
        { 'ip' => ["'127.0.0.1'"] },
        { 'port' => [514] },
      ],
    },
    {
      'type'    => 'syslog',
      'options' => [
        { 'flags' => ['no-multi-line', 'no-parse'] },
        { 'ip' => ["'127.0.0.1'"] },
        { 'keep-alive' => ['yes'] },
        { 'keep_hostname' => ['yes'] },
        { 'transport' => ['udp'] },
      ],
    },
  ],
}

Parameters

The following parameters are available in the syslog_ng::source defined type:

params

Data type: Data

An array of hashes or a single hash.

Default value: []

syslog_ng::template

Creates one or more templates in your configuration.

syslog_ng::template {'t_demo_filetemplate':
  params => [
    {
      'type'    => 'template',
      'options' => [
        '"$ISODATE $HOST $MSG\n"',
      ],
    },
    {
      'type'    => 'template_escape',
      'options' => [
        'no',
      ],
    },
  ],
}

Parameters

The following parameters are available in the syslog_ng::template defined type:

params

Data type: Data

An array of hashes or a single hash.

Default value: []

Functions

syslog_ng::generate_log

Type: Ruby 4.x API

Gererate log

syslog_ng::generate_log(Data $options)

Gererate log

Returns: String The generated log

options

Data type: Data

syslog_ng::generate_options

Type: Ruby 4.x API

Generate options

syslog_ng::generate_options(Hash[String[1], Variant[Integer, String]] $options)

Generate options

Returns: String The generated options

options

Data type: Hash[String[1], Variant[Integer, String]]

syslog_ng::generate_statement

Type: Ruby 4.x API

Generate statement

syslog_ng::generate_statement(String $id, String $type, Data $params)

Generate statement

Returns: String The generated statement

id

Data type: String

type

Data type: String

params

Data type: Data