Puppet Class: icinga2::feature::compatlog

Defined in:
manifests/feature/compatlog.pp

Overview

== Class: icinga2::feature::compatlog

This module configures the Icinga 2 feature compatlog.

=== Parameters

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

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

[*rotation_method*] Sets how often should the log file be rotated. Valid options are: HOURLY, DAILY, WEEKLY or MONTHLY. Icinga defaults to DAILY.

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: present)
  • log_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef)
  • rotation_method (Optional[Enum['DAILY', 'HOURLY', 'MONTHLY', 'WEEKLY']]) (defaults to: undef)


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
57
58
59
60
61
62
63
64
# File 'manifests/feature/compatlog.pp', line 20

class icinga2::feature::compatlog(
  Enum['absent', 'present']                                 $ensure          = present,
  Optional[Stdlib::Absolutepath]                            $log_dir         = undef,
  Optional[Enum['DAILY', 'HOURLY', 'MONTHLY', 'WEEKLY']]    $rotation_method = undef,
) {

  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 = {
    log_dir         => $log_dir,
    rotation_method => $rotation_method,
  }

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

  # import library 'compat'
  concat::fragment { 'icinga2::feature::compatlog':
    target  => "${conf_dir}/features-available/compatlog.conf",
    content => "library \"compat\"\n\n",
    order   => '05',
  }

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