Puppet Class: icinga::web

Defined in:
manifests/web.pp

Summary

Setup Icinga Web 2 including a database backend for user settings, PHP and a Webserver.

Overview

Parameters:

  • default_admin_user (String) (defaults to: 'icingaadmin')

    Set the initial name of the admin user.

  • default_admin_pass (Icinga::Secret) (defaults to: 'icingaadmin')

    Set the initial password for the admin user.

  • db_pass (Icinga::Secret)

    Password to connect the database.

  • apache_cgi_pass_auth (Boolean)

    Either turn on or off the apache cgi pass thru auth. An option available since Apache v2.4.15 and required for authenticated access to the Icinga Web Api.

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

  • api_pass (Icinga::Secret)

    Password to connect the Icinga 2 API.



45
46
47
48
49
50
51
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
# File 'manifests/web.pp', line 45

class icinga::web (
  Icinga::Secret                              $db_pass,
  Icinga::Secret                              $api_pass,
  Boolean                                     $apache_cgi_pass_auth,
  String                                      $default_admin_user = 'icingaadmin',
  Icinga::Secret                              $default_admin_pass = 'icingaadmin',
  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',
) {
  # install all required php extentions
  # by icingaweb (done by package dependencies) before PHP
  Package['icingaweb2']
  -> Class['php']
  -> Class['apache']
  -> Class['icingaweb2']

  # version if the used icingaweb2 puppet module
  $icingaweb2_version = load_module_metadata('icingaweb2')['version']

  #
  # Platform
  #
  case $facts['os']['family'] {
    '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 = {}
        }
      }

      $package_prefix = undef
    } # RedHat

    'debian': {
      $php_globals    = {}
      $package_prefix = 'php-'
    } # Debian

    default: {
      fail("'Your operatingsystem ${facts['os']['name']} is not supported.'")
    }
  }

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

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

  #
  # Apache
  #
  $manage_package = false

  package { ['icingaweb2', 'icingaweb2-module-pdfexport']:
    ensure => installed,
  }

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

  $web_conf_user = $apache::user

  include apache::vhosts

  include apache::mod::alias
  include apache::mod::mime
  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::proxy_http
  include apache::mod::ssl

  apache::custom_config { 'icingaweb2':
    ensure        => present,
    content       => template('icinga/apache_custom_default.conf.erb'),
    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
  #
  if versioncmp($icingaweb2_version, '4.0.0') < 0 {
    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,
      default_admin_username => $default_admin_user,
      default_admin_password => $default_admin_pass,
      import_schema          => lookup('icingaweb2::import_schema', undef, undef, true),
      config_backend         => 'db',
      conf_user              => $web_conf_user,
      manage_package         => $manage_package,
    }
  } else {
    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,
      default_admin_username => $default_admin_user,
      default_admin_password => $default_admin_pass,
      import_schema          => lookup('icingaweb2::import_schema', undef, undef, true),
      conf_user              => $web_conf_user,
      manage_package         => $manage_package,
    }
  }
}