Puppet Class: icingaweb2::module::director

Defined in:
manifests/module/director.pp

Overview

Class: icingaweb2::module::director

Install and configure the director module.

Parameters

ensure

Enable or disable module. Defaults to ‘present`

git_repository

Set a git repository URL. Defaults to github.

git_revision

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

db_type

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

db_host

Hostname of the database.

db_port

Port of the database. Defaults to ‘3306`

db_name

Name of the database.

db_username

Username for DB connection.

db_password

Password for DB connection.

import_schema

Import database schema. Defaults to ‘false`

kickstart

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

endpoint

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

api_host

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

api_port

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

api_username

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

api_password

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

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')
  • git_repository (String) (defaults to: 'https://github.com/Icinga/icingaweb2-module-director.git')
  • git_revision (Optional[String]) (defaults to: undef)
  • db_type (Enum['mysql', 'pgsql']) (defaults to: 'mysql')
  • db_host (Optional[String]) (defaults to: undef)
  • db_port (Integer[1,65535]) (defaults to: 3306)
  • db_name (Optional[String]) (defaults to: undef)
  • db_username (Optional[String]) (defaults to: undef)
  • db_password (Optional[String]) (defaults to: undef)
  • db_charset (Optional[String]) (defaults to: 'utf8')
  • import_schema (Optional[Boolean]) (defaults to: false)
  • kickstart (Optional[Boolean]) (defaults to: false)
  • endpoint (Optional[String]) (defaults to: undef)
  • api_host (String) (defaults to: 'localhost')
  • api_port (Integer[1,65535]) (defaults to: 5665)
  • api_username (Optional[String]) (defaults to: undef)
  • api_password (Optional[String]) (defaults to: undef)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
# File 'manifests/module/director.pp', line 55

class icingaweb2::module::director(
  Enum['absent', 'present'] $ensure         = 'present',
  String                    $git_repository = 'https://github.com/Icinga/icingaweb2-module-director.git',
  Optional[String]          $git_revision   = undef,
  Enum['mysql', 'pgsql']    $db_type        = 'mysql',
  Optional[String]          $db_host        = undef,
  Integer[1,65535]          $db_port        = 3306,
  Optional[String]          $db_name        = undef,
  Optional[String]          $db_username    = undef,
  Optional[String]          $db_password    = undef,
  Optional[String]          $db_charset     = 'utf8',
  Optional[Boolean]         $import_schema  = false,
  Optional[Boolean]         $kickstart      = false,
  Optional[String]          $endpoint       = undef,
  String                    $api_host       = 'localhost',
  Integer[1,65535]          $api_port       = 5665,
  Optional[String]          $api_username   = undef,
  Optional[String]          $api_password   = undef,
){
  $conf_dir        = $::icingaweb2::params::conf_dir
  $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 => $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 director migration run',
      onlyif  => 'icingacli 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'   => $api_password,
          }
        }
      }

      exec { 'director-kickstart':
        command => 'icingacli director kickstart run',
        onlyif  => 'icingacli 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,
    settings       => merge($db_settings, $kickstart_settings),
  }
}