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 (Optional[Stdlib::Host]) (defaults to: undef)

    Hostname of the database.

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

    Port of the database.

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

    Name of the database.

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

    Username for DB connection.

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

    Password for DB 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`.

  • db_charset (Optional[String]) (defaults to: 'utf8')


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

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',
  Optional[Stdlib::Host]         $db_host        = undef,
  Optional[Stdlib::Port]         $db_port        = undef,
  Optional[String]               $db_name        = undef,
  Optional[String]               $db_username    = undef,
  Optional[Icingaweb2::Secret]   $db_password    = undef,
  Optional[String]               $db_charset     = 'utf8',
  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,
) {

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

  Exec {
    user => 'root',
    path => $::path,
  }

  icingaweb2::config::resource { 'icingaweb2-module-director':
    type        => 'db',
    db_type     => $db_type,
    host        => $db_host,
    port        => $db_port,
    db_name     => $db_name,
    db_username => $db_username,
    db_password => icingaweb2::unwrap($db_password),
    db_charset  => $db_charset,
  }

  $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 => [ Package['icingacli'], Icingaweb2::Module['director'] ]
    }

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

}