Puppet Class: icingaweb2::module::icingadb

Defined in:
manifests/module/icingadb.pp

Summary

Manages the icingadb module. This module is still optional at the moment.

Overview

Note:

At first have a look at the [IcingaDB module documentation](icinga.com/docs/icinga-db/latest/doc/01-About/).

Parameters:

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

    Enable or disable module.

  • package_name (String)

    IicngaDB-Web module package name.

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

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

  • db_host (Stdlib::Host) (defaults to: 'localhost')

    Hostname of the IcingaDB database.

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

    Port of the IcingaDB database.

  • db_name (String) (defaults to: 'icingadb')

    Name of the IcingaDB database.

  • db_username (String) (defaults to: 'icingadb')

    Username for IcingaDB database connection.

  • db_password (Icingaweb2::Secret)

    Password for IcingaDB database connection.

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

    The character set to use for the IcingaDB database connection.

  • db_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’.

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

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

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

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

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

    Location of the CA root certificate. Only valid if db_use_tls is enabled.

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

    The client certificate in PEM format. Only valid if db_use_tls is enabled.

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

    The client private key in PEM format. Only valid if db_use_tls is enabled.

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

    The CA root certificate in PEM format. Only valid if db_use_tls is enabled.

  • db_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.

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

    Disable validation of the server certificate.

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

    Cipher to use for the encrypted database connection.

  • redis_host (Stdlib::Host) (defaults to: 'localhost')

    Redis host to connect.

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

    Connect ‘redis_host` om this port.

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

    Password for Redis connection.

  • redis_primary_host (Stdlib::Host) (defaults to: $redis_host)

    Alternative parameter to use for ‘redis_host`. Useful for high availability environments.

  • redis_primary_port (Optional[Stdlib::Port]) (defaults to: $redis_port)

    Alternative parameter to use for ‘redis_port`. Useful for high availability environments.

  • redis_primary_password (Optional[Icingaweb2::Secret]) (defaults to: $redis_password)

    Alternative parameter to use for ‘redis_passwod`. Useful for high availability environments.

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

    Fallback Redis host to connect if the first one fails.

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

    Port to connect on the fallback Redis server.

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

    Password for the second Redis server.

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

    Use tls encrypt connection for Redis. All Credentials are applied for both connections in a high availability environments.

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

    Client certificate in PEM format to authenticate to Redis. Only valid if redis_use_tls is enabled.

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

    Client private key in PEM format. Only valid if redis_use_tls is enabled.

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

    The CA certificate in PEM format. Only valid if redis_use_tls is enabled.

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

    Location of the client certificate. Only valid if redis_use_tls is enabled.

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

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

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

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

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

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

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

    A hash of command transports.



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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'manifests/module/icingadb.pp', line 122

class icingaweb2::module::icingadb (
  String                          $package_name,
  Icingaweb2::Secret              $db_password,
  Enum['absent', 'present']       $ensure                   = 'present',
  Enum['mysql', 'pgsql']          $db_type                  = 'mysql',
  Stdlib::Host                    $db_host                  = 'localhost',
  Optional[Stdlib::Port]          $db_port                  = undef,
  String                          $db_name                  = 'icingadb',
  String                          $db_username              = 'icingadb',
  Optional[String]                $db_charset               = undef,
  Optional[Boolean]               $db_use_tls               = undef,
  Optional[String]                $db_tls_cert              = undef,
  Optional[Icingaweb2::Secret]    $db_tls_key               = undef,
  Optional[String]                $db_tls_cacert            = undef,
  Optional[Stdlib::Absolutepath]  $db_tls_cert_file         = undef,
  Optional[Stdlib::Absolutepath]  $db_tls_key_file          = undef,
  Optional[Stdlib::Absolutepath]  $db_tls_cacert_file       = undef,
  Optional[Stdlib::Absolutepath]  $db_tls_capath            = undef,
  Optional[Boolean]               $db_tls_noverify          = undef,
  Optional[String]                $db_tls_cipher            = undef,
  Stdlib::Host                    $redis_host               = 'localhost',
  Optional[Stdlib::Port]          $redis_port               = undef,
  Optional[Icingaweb2::Secret]    $redis_password           = undef,
  Stdlib::Host                    $redis_primary_host       = $redis_host,
  Optional[Stdlib::Port]          $redis_primary_port       = $redis_port,
  Optional[Icingaweb2::Secret]    $redis_primary_password   = $redis_password,
  Optional[Stdlib::Host]          $redis_secondary_host     = undef,
  Optional[Stdlib::Port]          $redis_secondary_port     = undef,
  Optional[Icingaweb2::Secret]    $redis_secondary_password = undef,
  Optional[Boolean]               $redis_use_tls            = undef,
  Optional[String]                $redis_tls_cert           = undef,
  Optional[Icingaweb2::Secret]    $redis_tls_key            = undef,
  Optional[String]                $redis_tls_cacert         = undef,
  Optional[Stdlib::Absolutepath]  $redis_tls_cert_file      = undef,
  Optional[Stdlib::Absolutepath]  $redis_tls_key_file       = undef,
  Optional[Stdlib::Absolutepath]  $redis_tls_cacert_file    = undef,
  Hash[String, Any]               $settings                 = {},
  Hash[String, Hash]              $commandtransports        = {},
) {
  icingaweb2::assert_module()

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

  if $redis_use_tls {
    $redis_tls_files = icingaweb2::cert::files(
      'redis',
      $module_conf_dir,
      $redis_tls_key_file,
      $redis_tls_cert_file,
      $redis_tls_cacert_file,
      $redis_tls_key,
      $redis_tls_cert,
      $redis_tls_cacert,
    )
    $redis_settings = delete_undef_values({
        tls  => true,
        cert => $redis_tls_files['cert_file'],
        key  => $redis_tls_files['key_file'],
        ca   => $redis_tls_files['cacert_file'],
    })
    icingaweb2::tls::client { 'icingaweb2::module::icingadb redis client tls config':
      args  => $redis_tls_files,
    }
  } else {
    $redis_settings = {}
  }

  $_settings = {
    'icingaweb2-module-icingadb-config' => {
      'section_name' => 'icingadb',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => {
        resource => 'icingaweb2-module-icingadb',
      },
    },
    'icingaweb2-module-icingadb-redis' => {
      'section_name' => 'redis',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => $redis_settings,
    },
    'icingaweb2-module-icingadb-redis1' => {
      'section_name' => 'redis1',
      'target'       => "${module_conf_dir}/redis.ini",
      'settings'     => delete_undef_values({
          host     => $redis_primary_host,
          port     => $redis_primary_port,
          password => $redis_primary_password,
      }),
    },
    'icingaweb2-module-icingadb-redis2' => {
      'section_name' => 'redis2',
      'target'       => "${module_conf_dir}/redis.ini",
      'settings'     => delete_undef_values({
          host     => $redis_secondary_host,
          port     => $redis_secondary_port,
          password => $redis_secondary_password,
      }),
    },
    'icingaweb2-module-icingadb-settings' => {
      'section_name' => 'settings',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => delete_undef_values($settings),
    },
  }

  $db_tls = merge(delete($icingaweb2::config::tls, ['key', 'cert', 'cacert']), delete_undef_values(merge(icingaweb2::cert::files(
          'client',
          $module_conf_dir,
          $db_tls_key_file,
          $db_tls_cert_file,
          $db_tls_cacert_file,
          $db_tls_key,
          $db_tls_cert,
          $db_tls_cacert,
        ), {
          capath   => $db_tls_capath,
          noverify => $db_tls_noverify,
          cipher   => $db_tls_cipher,
  })))

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

  icingaweb2::resource::database { 'icingaweb2-module-icingadb':
    type         => $db_type,
    host         => $db_host,
    port         => pick($db_port, $icingaweb2::globals::port[$db_type]),
    database     => $db_name,
    username     => $db_username,
    password     => $db_password,
    charset      => $db_charset,
    use_tls      => $db_use_tls,
    tls_noverify => $db_tls['noverify'],
    tls_key      => $db_tls['key_file'],
    tls_cert     => $db_tls['cert_file'],
    tls_cacert   => $db_tls['cacert_file'],
    tls_capath   => $db_tls['capath'],
    tls_cipher   => $db_tls['cipher'],
  }

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

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