Puppet Class: icinga2::feature::mainlog

Defined in:
manifests/feature/mainlog.pp

Overview

== Class: icinga2::feature::mainlog

This module configures the Icinga 2 feature mainlog.

=== Parameters

[*ensure*] Set to 'present' enables the feature mainlog, 'absent' disabled it. Defaults to 'present'.

[*severity*] You can set the log severity to 'information', 'notice', 'warning' or 'debug'. Defaults to 'information'.

[*path*] Absolute path to the log file. Default depends on platform, '/var/log/icinga2/icinga2.log' on Linux and 'C:/ProgramData/icinga2/var/log/icinga2/icinga2.log' on Windows.

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: present)
  • severity (Icinga2::LogSeverity) (defaults to: 'information')
  • path (Stdlib::Absolutepath) (defaults to: "${::icinga2::globals::log_dir}/icinga2.log")


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
50
51
52
53
54
55
56
# File 'manifests/feature/mainlog.pp', line 18

class icinga2::feature::mainlog(
  Enum['absent', 'present']    $ensure   = present,
  Icinga2::LogSeverity         $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,
  }

}