Puppet Class: icinga2::feature::gelf

Defined in:
manifests/feature/gelf.pp

Summary

Configures the Icinga 2 feature gelf.

Overview

Parameters:

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

    Set to present enables the feature gelf, absent disables it.

  • host (Optional[Stdlib::Host]) (defaults to: undef)

    GELF receiver host address.

  • port (Optional[Stdlib::Port::Unprivileged]) (defaults to: undef)

    GELF receiver port.

  • source (Optional[String]) (defaults to: undef)

    Source name for this instance.

  • enable_ssl (Boolean) (defaults to: false)

    Either enable or disable SSL/TLS. Other SSL parameters are only affected if this is set to ‘true’.

  • ssl_key_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of the private key. Only valid if ssl is enabled.

  • ssl_cert_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of the certificate. Only valid if ssl is enabled.

  • ssl_cacert_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Location of the CA certificate. Only valid if ssl is enabled.

  • ssl_key (Optional[Stdlib::Base64]) (defaults to: undef)

    The private key in a base64 encoded string to store in spicified ssl_key_path file. Only valid if ssl is enabled.

  • ssl_cert (Optional[Stdlib::Base64]) (defaults to: undef)

    The certificate in a base64 encoded string to store in spicified ssl_cert_path file. Only valid if ssl is enabled.

  • ssl_cacert (Optional[Stdlib::Base64]) (defaults to: undef)

    The CA root certificate in a base64 encoded string to store in spicified ssl_cacert_path file. Only valid if ssl is enabled.

  • ssl_noverify (Optional[Boolean]) (defaults to: undef)

    Disable TLS peer verification.

  • enable_send_perfdata (Optional[Boolean]) (defaults to: undef)

    Enable performance data for ‘CHECK RESULT’ events.

  • enable_ha (Optional[Boolean]) (defaults to: undef)

    Enable the high availability functionality. Only valid in a cluster setup.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'manifests/feature/gelf.pp', line 49

class icinga2::feature::gelf(
  Enum['absent', 'present']                $ensure               = present,
  Optional[Stdlib::Host]                   $host                 = undef,
  Optional[Stdlib::Port::Unprivileged]     $port                 = undef,
  Optional[String]                         $source               = undef,
  Boolean                                  $enable_ssl           = false,
  Optional[Stdlib::Absolutepath]           $ssl_key_path         = undef,
  Optional[Stdlib::Absolutepath]           $ssl_cert_path        = undef,
  Optional[Stdlib::Absolutepath]           $ssl_cacert_path      = undef,
  Optional[Stdlib::Base64]                 $ssl_key              = undef,
  Optional[Stdlib::Base64]                 $ssl_cert             = undef,
  Optional[Stdlib::Base64]                 $ssl_cacert           = undef,
  Optional[Boolean]                        $ssl_noverify         = undef,
  Optional[Boolean]                        $enable_send_perfdata = undef,
  Optional[Boolean]                        $enable_ha            = undef,
) {

  if ! defined(Class['::icinga2']) {
    fail('You must include the icinga2 base class before using any icinga2 feature class!')
  }

  $owner    = $::icinga2::globals::user
  $group    = $::icinga2::globals::group
  $conf_dir = $::icinga2::globals::conf_dir
  $ssl_dir  = $::icinga2::globals::cert_dir

  $_ssl_key_mode = $::facts['os']['family'] ? {
    'windows' => undef,
    default   => '0600',
  }

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

  File {
    owner   => $owner,
    group   => $group,
  }


  if $enable_ssl {
    # Set defaults for certificate stuff
    if $ssl_key {
      if $ssl_key_path {
        $_ssl_key_path = $ssl_key_path }
      else {
        $_ssl_key_path = "${ssl_dir}/GelfWriter_gelf.key"
      }

      $_ssl_key = $::facts['os']['family'] ? {
        'windows' => regsubst($ssl_key, '\n', "\r\n", 'EMG'),
        default   => $ssl_key,
      }

      file { $_ssl_key_path:
        ensure    => file,
        mode      => $_ssl_key_mode,
        content   => $ssl_key,
        show_diff => false,
        tag       => 'icinga2::config::file',
      }
    } else {
      $_ssl_key_path = $ssl_key_path
    }

    if $ssl_cert {
      if $ssl_cert_path {
        $_ssl_cert_path = $ssl_cert_path }
      else {
        $_ssl_cert_path = "${ssl_dir}/GelfWriter_gelf.crt"
      }

      $_ssl_cert = $::facts['os']['family'] ? {
        'windows' => regsubst($ssl_cert, '\n', "\r\n", 'EMG'),
        default   => $ssl_cert,
      }

      file { $_ssl_cert_path:
        ensure  => file,
        content => $ssl_cert,
        tag     => 'icinga2::config::file',
      }
    } else {
      $_ssl_cert_path = $ssl_cert_path
    }

    if $ssl_cacert {
      if $ssl_cacert_path {
        $_ssl_cacert_path = $ssl_cacert_path }
      else {
        $_ssl_cacert_path = "${ssl_dir}/GelfWriter_gelf_ca.crt"
      }

      $_ssl_cacert = $::facts['os']['family'] ? {
        'windows' => regsubst($ssl_cacert, '\n', "\r\n", 'EMG'),
        default   => $ssl_cacert,
      }

      file { $_ssl_cacert_path:
        ensure  => file,
        content => $ssl_cacert,
        tag     => 'icinga2::config::file',
      }
    } else {
      $_ssl_cacert_path = $ssl_cacert_path
    }

    $attrs_ssl = {
      enable_tls        => $enable_ssl,
      insecure_noverify => $ssl_noverify,
      ca_path           => $_ssl_cacert_path,
      cert_path         => $_ssl_cert_path,
      key_path          => $_ssl_key_path,
    }
  } # enable_ssl
  else {
    $attrs_ssl = { enable_tls  => $enable_ssl }
  }


  # compose attributes
  $attrs = {
    host                 => $host,
    port                 => $port,
    source               => $source,
    enable_send_perfdata => $enable_send_perfdata,
    enable_ha            => $enable_ha,
  }

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

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

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