Puppet Class: icinga2::feature::notification

Defined in:
manifests/feature/notification.pp

Overview

== Class: icinga2::feature::notification

This module configures the Icinga 2 feature notification.

=== Parameters

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

[*enable_ha*] Notifications are load-balanced amongst all nodes in a zone. By default this functionality is enabled. If your nodes should send out notifications independently from any other nodes (this will cause duplicated notifications if not properly handled!), you can set enable_ha to false.

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: present)
  • enable_ha (Optional[Boolean]) (defaults to: undef)


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
50
51
52
53
54
55
56
57
58
59
60
# File 'manifests/feature/notification.pp', line 17

class icinga2::feature::notification(
  Enum['absent', 'present'] $ensure    = present,
  Optional[Boolean]         $enable_ha = 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 = {
    enable_ha => $enable_ha,
  }

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

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

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

}