Puppet Class: icinga::web

Defined in:
manifests/web.pp

Summary

Setup Icinga Web 2 including a database backend for user settings.

Overview

Parameters:

  • db_pass (String)

    Password to connect the database.

  • api_pass (String)

    Password to connect the Icinga 2 API.

  • backend_db_pass (String)

    Pasword to connect the IDO backend.

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

    What kind of database type to use.

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

    Database host to connect.

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

    Port to connect. Only affects for connection to remote database hosts.

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

    Name of the database.

  • db_user (String) (defaults to: 'icingaweb2')

    Database user name.

  • manage_database (Boolean) (defaults to: false)

    Create database.

  • api_host (Variant[Stdlib::Host, Array[Stdlib::Host]]) (defaults to: 'localhost')

    Single or list of Icinga 2 API endpoints to connect.

  • api_user (String) (defaults to: 'icingaweb2')

    Icinga 2 API user.

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

    What kind of database type to use as IDO backend.

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

    Database host to connect for the IDO backenend.

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

    Port to connect the IDO backend. Only affects for connection to remote database hosts.

  • backend_db_name (String) (defaults to: 'icinga2')

    Name of the IDO database backend.

  • backend_db_user (String) (defaults to: 'icinga2')

    IDO database backend user name.



52
53
54
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
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
# File 'manifests/web.pp', line 52

class icinga::web(
  String                                      $db_pass,
  String                                      $api_pass,
  String                                      $backend_db_pass,
  Enum['mysql', 'pgsql']                      $db_type          = 'mysql',
  Stdlib::Host                                $db_host          = 'localhost',
  Optional[Stdlib::Port::Unprivileged]        $db_port          = undef,
  String                                      $db_name          = 'icingaweb2',
  String                                      $db_user          = 'icingaweb2',
  Boolean                                     $manage_database  = false,
  Variant[Stdlib::Host, Array[Stdlib::Host]]  $api_host         = 'localhost',
  String                                      $api_user         = 'icingaweb2',
  Enum['mysql', 'pgsql']                      $backend_db_type  = 'mysql',
  Stdlib::Host                                $backend_db_host  = 'localhost',
  Optional[Stdlib::Port::Unprivileged]        $backend_db_port  = undef,
  String                                      $backend_db_name  = 'icinga2',
  String                                      $backend_db_user  = 'icinga2',
) {

  unless $backend_db_port {
    $_backend_db_port = $backend_db_type ? {
      'pgsql' => 5432,
      default => 3306,
    }
  } else {
    $_backend_db_port = $backend_db_port
  }

  unless $db_port {
    $_db_port = $db_type ? {
      'pgsql' => 5432,
      default => 3306,
    }
  } else {
    $_db_port = $db_port
  }

  #
  # Platform
  #
  case $::osfamily {
    'redhat': {
      case $facts[os][release][major] {
        '6': {
          $php_globals = {
            php_version => 'rh-php70',
            rhscl_mode => 'rhscl',
          }
        }
        '7': {
          $php_globals = {
            php_version => 'rh-php73',
            rhscl_mode => 'rhscl',
          }
        }
        default: {
          $php_globals = {}
        }
      }
      $php_extensions = {
        mbstring => { ini_prefix => '20-' },
        json     => { ini_prefix => '20-' },
        ldap     => { ini_prefix => '20-' },
        gd       => { ini_prefix => '20-' },
        xml      => { ini_prefix => '20-' },
        intl     => { ini_prefix => '20-' },
        mysqlnd  => { ini_prefix => '20-' },
        pgsql    => { ini_prefix => '20-' },
      }
    } # RedHat

    'debian': {
      if $facts[os][distro][codename] == 'focal' {
        $php_globals = {
          php_version => '7.4',
        }
      } else {
        $php_globals = {}
      }
      $php_extensions = {
        mbstring => {},
        json     => {},
        ldap     => {},
        gd       => {},
        xml      => {},
        intl     => {},
        mysql    => {},
        pgsql    => {},
      }
    } # Debian

    default: {
      fail("'Your operatingsystem ${::operatingsystem} is not supported.'")
    }
  }

  #
  # PHP
  #
  class { '::php::globals':
    * => $php_globals,
  }

  class { '::php':
    ensure        => installed,
    manage_repos  => false,
    apache_config => false,
    fpm           => true,
    extensions    => $php_extensions,
    dev           => false,
    composer      => false,
    pear          => false,
    phpunit       => false,
    require       => Class['::php::globals'],
  }

  #
  # Apache
  #
  $manage_package = false

  Package['icingaweb2']
    -> Class['apache']

  package { 'icingaweb2':
    ensure => installed,
  }

  class { '::apache':
    default_mods => false,
    mpm_module   => 'worker',
  }

  apache::listen { '80': }

  $web_conf_user = $::apache::user

  include ::apache::mod::alias
  include ::apache::mod::status
  include ::apache::mod::dir
  include ::apache::mod::env
  include ::apache::mod::rewrite
  include ::apache::mod::proxy
  include ::apache::mod::proxy_fcgi
  include ::apache::mod::status
  include ::apache::mod::ssl

  apache::custom_config { 'icingaweb2':
    ensure        => present,
    source        => 'puppet:///modules/icingaweb2/examples/apache2/for-mod_proxy_fcgi.conf',
    verify_config => false,
    priority      => false,
  }

  #
  # Database
  #
  if $manage_database {
    class { '::icinga::web::database':
      db_type       => $db_type,
      db_name       => $db_name,
      db_user       => $db_user,
      db_pass       => $db_pass,
      web_instances => [ 'localhost' ],
      before        => Class['icingaweb2'],
    }
    $_db_host = 'localhost'
  } else {
    if $db_type != 'pgsql' {
      include ::mysql::client
    } else {
      include ::postgresql::client
    }
    $_db_host = $db_host
  }

  #
  # Icinga Web 2
  #
  class { 'icingaweb2':
    db_type        => $db_type,
    db_host        => $_db_host,
    db_port        => $_db_port,
    db_name        => $db_name,
    db_username    => $db_user,
    db_password    => $db_pass,
    import_schema  => true,
    config_backend => 'db',
    conf_user      => $web_conf_user,
    manage_package => $manage_package,
  }

  class { '::icingaweb2::module::monitoring':
    ido_type        => $backend_db_type,
    ido_host        => $backend_db_host,
    ido_port        => $_backend_db_port,
    ido_db_name     => $backend_db_name,
    ido_db_username => $backend_db_user,
    ido_db_password => $backend_db_pass,
  }

  any2array($api_host).each |Stdlib::Host $host| {
    ::icingaweb2::module::monitoring::commandtransport { $host:
      transport => 'api',
      host      => $host,
      username  => $api_user,
      password  => $api_pass,
    }
  }

}