Puppet Class: icinga2::feature::mainlog

Defined in:
manifests/feature/mainlog.pp

Summary

Configures the Icinga 2 feature mainlog.

Overview

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: present)

    Set to ‘present’ enables the feature mainlog, ‘absent’ disabled it.

  • severity (Icinga::LogLevel) (defaults to: 'information')

    You can set the log severity to ‘information’, ‘notice’, ‘warning’ or ‘debug’.

  • path (Stdlib::Absolutepath) (defaults to: "${icinga2::globals::log_dir}/icinga2.log")

    Absolute path to the log file.



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
# File 'manifests/feature/mainlog.pp', line 13

class icinga2::feature::mainlog (
  Enum['absent', 'present']    $ensure   = present,
  Icinga::LogLevel             $severity = 'information',
  Stdlib::Absolutepath         $path     = "${icinga2::globals::log_dir}/icinga2.log",
) {
  if ! defined(Class['icinga2']) {
    fail('You must include the icinga2 base class before using any icinga2 feature class!')
  }

  $conf_dir = $icinga2::globals::conf_dir
  $_notify  = $ensure ? {
    'present' => Class['icinga2::service'],
    default   => undef,
  }

  # compose attributes
  $attrs = {
    'severity' => $severity,
    'path'     => $path,
  }

  # create object
  icinga2::object { 'icinga2::object::FileLogger::mainlog':
    object_name => 'main-log',
    object_type => 'FileLogger',
    attrs       => delete_undef_values($attrs),
    attrs_list  => keys($attrs),
    target      => "${conf_dir}/features-available/mainlog.conf",
    order       => 10,
    notify      => $_notify,
  }

  # manage feature
  icinga2::feature { 'mainlog':
    ensure => $ensure,
  }
}