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'])

    Enable or disable module.

  • package_name (String[1])

    IicngaDB-Web module package name.

  • db_type (Enum['mysql', 'pgsql'])

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

  • db_resource_name (String[1])

    Name for the icingadb database resource.

  • db_host (Stdlib::Host)

    Hostname of the IcingaDB database.

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

    Port of the IcingaDB database.

  • db_name (String[1])

    Name of the IcingaDB database.

  • db_username (String[1])

    Username for IcingaDB database connection.

  • db_password (Optional[Icinga::Secret]) (defaults to: undef)

    Password for IcingaDB database connection.

  • db_charset (Optional[String[1]]) (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[Icinga::Secret]) (defaults to: undef)

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

  • db_tls_cacert (Optional[String[1]]) (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[1]]) (defaults to: undef)

    Cipher to use for the encrypted database connection.

  • redis_host (Stdlib::Host)

    Redis host to connect.

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

    Connect ‘redis_host` om this port.

  • redis_password (Optional[Icinga::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[Icinga::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[Icinga::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[1]]) (defaults to: undef)

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

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

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

  • redis_tls_cacert (Optional[String[1]]) (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[1], Any])

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

  • commandtransports (Hash[String[1], Hash])

    A hash of command transports.



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
# File 'manifests/module/icingadb.pp', line 125

class icingaweb2::module::icingadb (
  Enum['absent', 'present']       $ensure,
  String[1]                       $package_name,
  Stdlib::Host                    $redis_host,
  Hash[String[1], Hash]           $commandtransports,
  Hash[String[1], Any]            $settings,
  Enum['mysql', 'pgsql']          $db_type,
  String[1]                       $db_resource_name,
  Stdlib::Host                    $db_host,
  String[1]                       $db_name,
  String[1]                       $db_username,
  Optional[Stdlib::Port]          $db_port                  = undef,
  Optional[Icinga::Secret]        $db_password              = undef,
  Optional[String[1]]             $db_charset               = undef,
  Optional[Boolean]               $db_use_tls               = undef,
  Optional[String]                $db_tls_cert              = undef,
  Optional[Icinga::Secret]        $db_tls_key               = undef,
  Optional[String[1]]             $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[1]]             $db_tls_cipher            = undef,
  Optional[Stdlib::Port]          $redis_port               = undef,
  Optional[Icinga::Secret]        $redis_password           = undef,
  Stdlib::Host                    $redis_primary_host       = $redis_host,
  Optional[Stdlib::Port]          $redis_primary_port       = $redis_port,
  Optional[Icinga::Secret]        $redis_primary_password   = $redis_password,
  Optional[Stdlib::Host]          $redis_secondary_host     = undef,
  Optional[Stdlib::Port]          $redis_secondary_port     = undef,
  Optional[Icinga::Secret]        $redis_secondary_password = undef,
  Optional[Boolean]               $redis_use_tls            = undef,
  Optional[String[1]]             $redis_tls_cert           = undef,
  Optional[Icinga::Secret]        $redis_tls_key            = undef,
  Optional[String[1]]             $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,
) {
  require icingaweb2

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

  $redis_tls = icinga::cert::files(
    'redis',
    $cert_dir,
    $redis_tls_key_file,
    $redis_tls_cert_file,
    $redis_tls_cacert_file,
    $redis_tls_key,
    $redis_tls_cert,
    $redis_tls_cacert,
  )

  $db_tls = icinga::cert::files(
    $db_username,
    $cert_dir,
    $db_tls_key_file,
    $db_tls_cert_file,
    $db_tls_cacert_file,
    $db_tls_key,
    $db_tls_cert,
    $db_tls_cacert,
  )

  if $redis_use_tls {
    $redis_settings = delete_undef_values({
        tls  => true,
        cert => $redis_tls['cert_file'],
        key  => $redis_tls['key_file'],
        ca   => icingaweb2::pick($redis_tls['cacert_file'], $icingaweb2::config::tls['cacert_file']),
    })
  } else {
    $redis_settings = {}
  }

  $_settings = {
    'icingaweb2-module-icingadb-config' => {
      'section_name' => 'icingadb',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => {
        resource => $db_resource_name,
      },
    },
    '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),
    },
  }

  class { 'icingaweb2::module::icingadb::install': }
  -> class { 'icingaweb2::module::icingadb::config': }
  contain icingaweb2::module::icingadb::install
  contain icingaweb2::module::icingadb::config
}