Puppet Class: icingaweb2::module::monitoring

Defined in:
manifests/module/monitoring.pp

Summary

Manages the monitoring module. This module is mandatory for probably every setup.

Overview

Requirements:

* IDO feature in Icinga 2 (MySQL or PostgreSQL)
* `ApiUser` object in Icinga 2 with proper permissions

class {'icingaweb2::module::monitoring':
  ido_host        => 'localhost',
  ido_type        => 'mysql',
  ido_db_name     => 'icinga2',
  ido_db_username => 'icinga2',
  ido_db_password => 'supersecret',
  commandtransports => {
    icinga2 => {
      transport => 'api',
      username  => 'icingaweb2',
      password  => 'supersecret',
    }
  }
}
Note:

At first have a look at the [Monitoring module documentation](www.icinga.com/docs/icingaweb2/latest/modules/monitoring/doc/01-About/).

Examples:

This module is mandatory for almost every setup. It connects your Icinga Web interface to the Icinga 2 core. Current and history information are queried through the IDO database. Actions such as ‘Check Now`, `Set Downtime` or `Acknowledge` are send to the Icinga 2 API.

Parameters:

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

    Enable or disable module.

  • protected_customvars (Variant[String, Array[String]]) (defaults to: ['*pw*', '*pass*', 'community'])

    Custom variables in Icinga 2 may contain sensible information. Set patterns for custom variables that should be hidden in the web interface.

  • manage_package (Boolean) (defaults to: true)

    Set to ‘false` as Fix for Icinga Web >= 2.12.0 to do not manage the removed package `icingaweb2-module-monitoring` (only Debian/Ubuntu). See issue #368 (github.com/Icinga/puppet-icingaweb2/issues/368).

  • ido_type (Enum['mysql', 'pgsql']) (defaults to: 'mysql')

    Type of your IDO database. Either ‘mysql` or `pgsql`.

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

    Hostname of the IDO database.

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

    Port of the IDO database.

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

    Name of the IDO database.

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

    Username for IDO DB connection.

  • ido_db_password (Optional[Icingaweb2::Secret]) (defaults to: undef)

    Password for IDO DB connection.

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

    The character set to use for the database connection.

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

    Either enable or disable TLS encryption to the database. Other TLS parameters are only affected if this is set to ‘true’.

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

    Location of the private key for client authentication. Only valid if tls is enabled.

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

    Location of the certificate for client authentication. Only valid if tls is enabled.

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

    Location of the ca certificate. Only valid if tls is enabled.

  • tls_key (Optional[Icingaweb2::Secret]) (defaults to: undef)

    The private key to store in spicified ‘tls_key_file` file. Only valid if tls is enabled.

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

    The certificate to store in spicified ‘tls_cert_file` file. Only valid if tls is enabled.

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

    The ca certificate to store in spicified ‘tls_cacert_file` file. Only valid if tls is enabled.

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

    The file path to the directory that contains the trusted SSL CA certificates, which are stored in PEM format. Only available for the mysql database.

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

    Disable validation of the server certificate.

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

    Cipher to use for the encrypted database connection.

  • settings (Hash[String, Any]) (defaults to: {})

    General configuration of module monitoring. See official Icinga [documentation](icinga.com/docs/icinga-web/latest/modules/monitoring/doc/03-Configuration)

  • commandtransports (Hash) (defaults to: {})

    A hash of command transports.



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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'manifests/module/monitoring.pp', line 99

class icingaweb2::module::monitoring (
  Enum['absent', 'present']      $ensure               = 'present',
  Variant[String, Array[String]] $protected_customvars = ['*pw*', '*pass*', 'community'],
  Enum['mysql', 'pgsql']         $ido_type             = 'mysql',
  Boolean                        $manage_package       = true,
  Optional[Stdlib::Host]         $ido_host             = undef,
  Optional[Stdlib::Port]         $ido_port             = undef,
  Optional[String]               $ido_db_name          = undef,
  Optional[String]               $ido_db_username      = undef,
  Optional[Icingaweb2::Secret]   $ido_db_password      = undef,
  Optional[String]               $ido_db_charset       = undef,
  Optional[Boolean]              $use_tls              = undef,
  Optional[Stdlib::Absolutepath] $tls_key_file         = undef,
  Optional[Stdlib::Absolutepath] $tls_cert_file        = undef,
  Optional[Stdlib::Absolutepath] $tls_cacert_file      = undef,
  Optional[Stdlib::Absolutepath] $tls_capath           = undef,
  Optional[Icingaweb2::Secret]   $tls_key              = undef,
  Optional[String]               $tls_cert             = undef,
  Optional[String]               $tls_cacert           = undef,
  Optional[Boolean]              $tls_noverify         = undef,
  Optional[String]               $tls_cipher           = undef,
  Hash[String, Any]              $settings             = {},
  Hash                           $commandtransports    = {},
) {
  icingaweb2::assert_module()

  $conf_dir        = $icingaweb2::globals::conf_dir
  $module_conf_dir = "${conf_dir}/modules/monitoring"

  case $facts['os']['family'] {
    'Debian': {
      if $manage_package {
        $install_method = 'package'
        $package_name   = 'icingaweb2-module-monitoring'
      } else {
        $install_method = 'none'
        $package_name   = undef
      }
    }
    default: {
      $install_method = 'none'
      $package_name   = undef
    }
  }

  $tls = merge(delete($icingaweb2::config::tls, ['key', 'cert', 'cacert']), delete_undef_values(merge(icingaweb2::cert::files(
          'client',
          $module_conf_dir,
          $tls_key_file,
          $tls_cert_file,
          $tls_cacert_file,
          $tls_key,
          $tls_cert,
          $tls_cacert,
        ), {
          capath   => $tls_capath,
          noverify => $tls_noverify,
          cipher   => $tls_cipher,
  })))

  icingaweb2::tls::client { 'icingaweb2::module::monitoring tls client config':
    args => $tls,
  }

  icingaweb2::resource::database { 'icingaweb2-module-monitoring':
    type         => $ido_type,
    host         => $ido_host,
    port         => pick($ido_port, $icingaweb2::globals::port[$ido_type]),
    database     => $ido_db_name,
    username     => $ido_db_username,
    password     => $ido_db_password,
    charset      => $ido_db_charset,
    use_tls      => $use_tls,
    tls_noverify => $tls['noverify'],
    tls_key      => $tls['key_file'],
    tls_cert     => $tls['cert_file'],
    tls_cacert   => $tls['cacert_file'],
    tls_capath   => $tls['capath'],
    tls_cipher   => $tls['cipher'],
  }

  $backend_settings = {
    'type'     => 'ido',
    'resource' => 'icingaweb2-module-monitoring',
  }

  $security_settings = {
    'protected_customvars' => $protected_customvars ? {
      String        => $protected_customvars,
      Array[String] => join($protected_customvars, ','),
    },
  }

  $_settings = {
    'module-monitoring-backends' => {
      'section_name' => 'backends',
      'target'       => "${module_conf_dir}/backends.ini",
      'settings'     => delete_undef_values($backend_settings),
    },
    'module-monitoring-security' => {
      'section_name' => 'security',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => delete_undef_values($security_settings),
    },
    'module-monitoring-general' => {
      'section_name' => 'settings',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => delete_undef_values($settings),
    },
  }

  create_resources('icingaweb2::module::monitoring::commandtransport', $commandtransports)

  icingaweb2::module { 'monitoring':
    ensure         => $ensure,
    install_method => $install_method,
    package_name   => $package_name,
    settings       => $_settings,
  }
}