Puppet Class: icingaweb2::module::director

Defined in:
manifests/module/director.pp

Summary

Installs and configures the director module.

Overview

Note:

If you want to use ‘git` as `install_method`, the CLI `git` command has to be installed. You can manage it yourself as package resource or declare the package name in icingaweb2 class parameter `extra_packages`.

Note:

Please checkout the [Director module documentation](www.icinga.com/docs/director/latest/) for requirements.

Examples:

class { 'icingaweb2::module::director':
  git_revision  => 'v1.7.2',
  db_host       => 'localhost',
  db_name       => 'director',
  db_username   => 'director',
  db_password   => 'supersecret',
  import_schema => true,
  kickstart     => true,
  endpoint      => 'puppet-icingaweb2.localdomain',
  api_username  => 'director',
  api_password  => 'supersecret',
  require       => Mysql::Db['director']
}

Parameters:

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

    Enable or disable module.

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

    Target directory of the module.

  • git_repository (String) (defaults to: 'https://github.com/Icinga/icingaweb2-module-director.git')

    Set a git repository URL.

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

    Set either a branch or a tag name, eg. ‘master` or `v1.3.2`.

  • install_method (Enum['git', 'package', 'none']) (defaults to: 'git')

    Install methods are ‘git`, `package` and `none` is supported as installation method.

  • package_name (String) (defaults to: 'icingaweb2-module-director')

    Package name of the module. This setting is only valid in combination with the installation method ‘package`.

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

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

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

    Hostname of the database.

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

    Port of the database.

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

    Name of the database.

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

    Username for DB connection.

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

    Password for DB connection.

  • db_charset (String) (defaults to: 'utf8')

    Character set to use for the database.

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

  • import_schema (Boolean) (defaults to: false)

    Import database schema.

  • kickstart (Boolean) (defaults to: false)

    Run kickstart command after database migration. This requires ‘import_schema` to be `true`.

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

    Endpoint object name of Icinga 2 API. This setting is only valid if ‘kickstart` is `true`.

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

    Icinga 2 API hostname. This setting is only valid if ‘kickstart` is `true`.

  • api_port (Stdlib::Port) (defaults to: 5665)

    Icinga 2 API port. This setting is only valid if ‘kickstart` is `true`.

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

    Icinga 2 API username. This setting is only valid if ‘kickstart` is `true`.

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

    Icinga 2 API password. This setting is only valid if ‘kickstart` is `true`.



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

class icingaweb2::module::director (
  Enum['absent', 'present']      $ensure          = 'present',
  Optional[Stdlib::Absolutepath] $module_dir      = undef,
  String                         $git_repository  = 'https://github.com/Icinga/icingaweb2-module-director.git',
  Optional[String]               $git_revision    = undef,
  Enum['git', 'package', 'none'] $install_method  = 'git',
  String                         $package_name    = 'icingaweb2-module-director',
  Enum['mysql', 'pgsql']         $db_type         = 'mysql',
  Stdlib::Host                   $db_host         = 'localhost',
  Optional[Stdlib::Port]         $db_port         = undef,
  String                         $db_name         = 'director',
  String                         $db_username     = 'director',
  Optional[Icingaweb2::Secret]   $db_password     = undef,
  String                         $db_charset      = 'utf8',
  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,
  Boolean                        $import_schema   = false,
  Boolean                        $kickstart       = false,
  Optional[String]               $endpoint        = undef,
  Stdlib::Host                   $api_host        = 'localhost',
  Stdlib::Port                   $api_port        = 5665,
  Optional[String]               $api_username    = undef,
  Optional[Icingaweb2::Secret]   $api_password    = undef,
) {
  icingaweb2::assert_module()

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

  $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,
  })))

  Exec {
    user     => 'root',
    path     => $facts['path'],
    provider => 'shell',
  }

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

  icingaweb2::resource::database { 'icingaweb2-module-director':
    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      => $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'],
  }

  $db_settings = {
    'module-director-db' => {
      'section_name' => 'db',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => {
        'resource'   => 'icingaweb2-module-director',
      },
    },
  }

  if $import_schema {
    ensure_packages(['icingacli'], { 'ensure' => 'present' })

    exec { 'director-migration':
      command => "${icingacli_bin} director migration run",
      onlyif  => "${icingacli_bin} director migration pending",
      require => [Icingaweb2::Tls::Client['icingaweb2::module::director tls client config'], Icingaweb2::Module['director'], Package['icingacli']],
    }

    if $kickstart {
      $kickstart_settings = {
        'module-director-config' => {
          'section_name' => 'config',
          'target'       => "${module_conf_dir}/kickstart.ini",
          'settings'     => {
            'endpoint'   => $endpoint,
            'host'       => $api_host,
            'port'       => $api_port,
            'username'   => $api_username,
            'password'   => icingaweb2::unwrap($api_password),
          },
        },
      }

      exec { 'director-kickstart':
        command => "${icingacli_bin} director kickstart run",
        onlyif  => "${icingacli_bin} director kickstart required",
        require => Exec['director-migration'],
      }
    } else {
      $kickstart_settings = {}
    }
  } else {
    $kickstart_settings = {}
  }

  icingaweb2::module { 'director':
    ensure         => $ensure,
    git_repository => $git_repository,
    git_revision   => $git_revision,
    install_method => $install_method,
    module_dir     => $module_dir,
    package_name   => $package_name,
    settings       => merge($db_settings, $kickstart_settings),
  }
}