Puppet Class: icinga

Inherits:
icinga::params
Inherited by:
icinga::spec
Defined in:
manifests/init.pp

Overview

Class: icinga

This is the main icinga class

Parameters

Standard class parameters Define the general class behaviour and customizations

dependencies_class

The name of the class that installs dependencies and prerequisite resources needed by this module. Default is $graylog2::dependencies which uses Example42 modules. Set to ” false to not install any dependency (you must provide what’s defined in graylog2/manifests/dependencies.pp in some way). Set directy the name of a custom class to manage there the dependencies

my_class

Name of a custom class to autoload to manage module’s customizations If defined, icinga class will automatically “include $my_class” Can be defined also by the (top scope) variable $icinga_myclass

source

Sets the content of source parameter for main configuration file If defined, icinga main config file will have the param: source => $source Can be defined also by the (top scope) variable $icinga_source

source_dir

If defined, the whole icinga configuration directory content is retrieved recursively from the specified source (source => $source_dir , recurse => true) Can be defined also by the (top scope) variable $icinga_source_dir

source_dir_purge

If set to true (default false) the existing configuration directory is mirrored with the content retrieved from source_dir (source => $source_dir , recurse => true , purge => true) Can be defined also by the (top scope) variable $icinga_source_dir_purge

template

Sets the path to the template to use as content for main configuration file If defined, icinga main config file has: content => content(“$template”) Note source and template parameters are mutually exclusive: don’t use both Can be defined also by the (top scope) variable $icinga_template

options

An hash of custom options to be used in templates for arbitrary settings. Can be defined also by the (top scope) variable $icinga_options

service_autorestart

Automatically restarts the icinga service when there is a change in configuration files. Default: true, Set to false if you don’t want to automatically restart the service.

version

The package version, used in the ensure parameter of package type. Default: present. Can be ‘latest’ or a specific version number. Note that if the argument absent (see below) is set to true, the package is removed, whatever the value of version parameter.

absent

Set to ‘true’ to remove package(s) installed by module Can be defined also by the (top scope) variable $icinga_absent

disable

Set to ‘true’ to disable service(s) managed by module Can be defined also by the (top scope) variable $icinga_disable

disableboot

Set to ‘true’ to disable service(s) at boot, without checks if it’s running Use this when the service is managed by a tool like a cluster software Can be defined also by the (top scope) variable $icinga_disableboot

monitor

Set to ‘true’ to enable monitoring of the services provided by the module Can be defined also by the (top scope) variables $icinga_monitor and $monitor

monitor_tool

Define which monitor tools (ad defined in Example42 monitor module) you want to use for icinga checks Can be defined also by the (top scope) variables $icinga_monitor_tool and $monitor_tool

monitor_target

The Ip address or hostname to use as a target for monitoring tools. Default is the fact $ipaddress Can be defined also by the (top scope) variables $icinga_monitor_target and $monitor_target

puppi

Set to ‘true’ to enable creation of module data files that are used by puppi Can be defined also by the (top scope) variables $icinga_puppi and $puppi

puppi_helper

Specify the helper to use for puppi commands. The default for this module is specified in params.pp and is generally a good choice. You can customize the output of puppi commands for this module using another puppi helper. Use the define puppi::helper to create a new custom helper Can be defined also by the (top scope) variables $icinga_puppi_helper and $puppi_helper

debug

Set to ‘true’ to enable modules debugging Can be defined also by the (top scope) variables $icinga_debug and $debug

audit_only

Set to ‘true’ if you don’t intend to override existing configuration files and want to audit the difference between existing files and the ones managed by Puppet. Can be defined also by the (top scope) variables $icinga_audit_only and $audit_only

Default class params - As defined in icinga::params. Note that these variables are mostly defined and used in the module itself, overriding the default values might not affected all the involved components. Set and override them only if you know what you’re doing. Note also that you can’t override/set them via top scope variables.

package

The name of icinga package

service

The name of icinga service

service_status

If the icinga service init script supports status argument

process

The name of icinga process

process_args

The name of icinga arguments. Used by puppi and monitor. Used only in case the icinga process name is generic (java, ruby…)

process_user

The name of the user icinga runs with. Used by puppi and monitor.

config_dir

Main configuration directory. Used by puppi

config_file

Main configuration file path

config_file_mode

Main configuration file path mode

config_file_owner

Main configuration file path owner

config_file_group

Main configuration file path group

config_file_init

Path of configuration file sourced by init script

pid_file

Path of pid file. Used by monitor

data_dir

Path of application data directory. Used by puppi

log_dir

Base logs directory. Used by puppi

log_file

Log file(s). Used by puppi

manage_repos

Should the icinga software repositories be managed by us. Default: false

enable_debian_repo_legacy

If true, both Debian, Mint and Ubuntu will use the Debian repo, no matter the manage_repos value. Default: true This directive exists for legacy reasons only and should be set to false on new installs.

template_settings_templates

Template to use for icinga/settings/templates.cfg

template_commands_general

Template to use for icinga/commands/general.cfg

template_commands_extra

Template to use for icinga/commands/extra.cfg

template_commands_special

Template to use for icinga/commands/special.cfg

template_settings_contacts

Template to use for icinga/settings/contacts.cfg

template_settings_timeperiods

Template to use for icinga/settings/timeperiods.cfg

template_hostgroups_all

Template to use for icinga/hostgroups/all.cfg

Examples

You can use this class in 2 ways:

  • Set variables (at top scope level on in a ENC) and “include icinga”

  • Call icinga as a parametrized class

See README for details.

Author

Alessandro Franceschi <al@lab42.it/>

Parameters:

  • extra_dir_source (Any) (defaults to: params_lookup( 'extra_dir_source' ))
  • services_hash (Any) (defaults to: params_lookup( 'services_hash' ))
  • hosts_hash (Any) (defaults to: params_lookup( 'hosts_hash' ))
  • hostgroups_hash (Any) (defaults to: params_lookup( 'hostgroups_hash' ))
  • dependencies_class (Any) (defaults to: params_lookup( 'dependencies_class' ))
  • enable_icingaweb (Any) (defaults to: params_lookup( 'enable_icingaweb' ))
  • template_icingaweb (Any) (defaults to: params_lookup( 'template_icingaweb' ))
  • source_dir_icingaweb (Any) (defaults to: params_lookup( 'source_dir_icingaweb' ))
  • source_dir_purge_icingaweb (Any) (defaults to: params_lookup( 'source_dir_purge_icingaweb' ))
  • config_dir_icingaweb (Any) (defaults to: params_lookup( 'config_dir_icingaweb' ))
  • config_file_icingaweb (Any) (defaults to: params_lookup( 'config_file_icingaweb' ))
  • config_file_mode_icingaweb (Any) (defaults to: params_lookup( 'config_file_mode_icingaweb' ))
  • config_file_owner_icingaweb (Any) (defaults to: params_lookup( 'config_file_owner_icingaweb' ))
  • config_file_group_icingaweb (Any) (defaults to: params_lookup( 'config_file_group_icingaweb' ))
  • apache_icingaweb_config (Any) (defaults to: params_lookup( 'apache_icingaweb_config' ))
  • db_host_icingaweb (Any) (defaults to: params_lookup( 'db_host_icingaweb' ))
  • db_name_icingaweb (Any) (defaults to: params_lookup( 'db_name_icingaweb' ))
  • db_user_icingaweb (Any) (defaults to: params_lookup( 'db_user_icingaweb' ))
  • db_password_icingaweb (Any) (defaults to: params_lookup( 'db_password_icingaweb' ))
  • ido_pid_file (Any) (defaults to: params_lookup( 'ido_pid_file' ))
  • ido_socket_file (Any) (defaults to: params_lookup( 'ido_socket_file' ))
  • idoutilspackage (Any) (defaults to: params_lookup( 'idoutilspackage' ))
  • enable_idoutils (Any) (defaults to: params_lookup( 'enable_idoutils' ))
  • template_idoutils (Any) (defaults to: params_lookup( 'template_idoutils' ))
  • db_host_idoutils (Any) (defaults to: params_lookup( 'db_host_idoutils' ))
  • db_name_idoutils (Any) (defaults to: params_lookup( 'db_name_idoutils' ))
  • db_user_idoutils (Any) (defaults to: params_lookup( 'db_user_idoutils' ))
  • db_password_idoutils (Any) (defaults to: params_lookup( 'db_password_idoutils' ))
  • phpmysql_package (Any) (defaults to: params_lookup( 'phpmysql_package' ))
  • icingacgipackage (Any) (defaults to: params_lookup( 'icingacgipackage' ))
  • enable_icingacgi (Any) (defaults to: params_lookup( 'enable_icingacgi' ))
  • apache_icingacgi_config (Any) (defaults to: params_lookup( 'apache_icingacgi_config' ))
  • apache_icingacgi_target (Any) (defaults to: params_lookup( 'apache_icingacgi_target' ))
  • check_external_commands (Any) (defaults to: params_lookup( 'check_external_commands' ))
  • plugins (Any) (defaults to: params_lookup( 'plugins' ))
  • use_ssl (Any) (defaults to: params_lookup( 'use_ssl' ))
  • cachedir (Any) (defaults to: params_lookup( 'cachedir' ))
  • temp_dir (Any) (defaults to: params_lookup( 'temp_dir' ))
  • resourcefile (Any) (defaults to: params_lookup( 'resourcefile' ))
  • statusfile (Any) (defaults to: params_lookup( 'statusfile' ))
  • commandfile (Any) (defaults to: params_lookup( 'commandfile' ))
  • resultpath (Any) (defaults to: params_lookup( 'resultpath' ))
  • retentionfile (Any) (defaults to: params_lookup( 'retentionfile' ))
  • p1file (Any) (defaults to: params_lookup( 'p1file' ))
  • nrpepluginpackage (Any) (defaults to: params_lookup( 'nrpepluginpackage' ))
  • htpasswdfile (Any) (defaults to: params_lookup( 'htpasswdfile' ))
  • template_htpasswdfile (Any) (defaults to: params_lookup( 'template_htpasswdfile' ))
  • my_class (Any) (defaults to: params_lookup( 'my_class' ))
  • source (Any) (defaults to: params_lookup( 'source' ))
  • source_dir (Any) (defaults to: params_lookup( 'source_dir' ))
  • source_dir_purge (Any) (defaults to: params_lookup( 'source_dir_purge' ))
  • template (Any) (defaults to: params_lookup( 'template' ))
  • service_autorestart (Any) (defaults to: params_lookup( 'service_autorestart' , 'global' ))
  • options (Any) (defaults to: params_lookup( 'options' ))
  • version (Any) (defaults to: params_lookup( 'version' ))
  • absent (Any) (defaults to: params_lookup( 'absent' ))
  • disable (Any) (defaults to: params_lookup( 'disable' ))
  • disableboot (Any) (defaults to: params_lookup( 'disableboot' ))
  • monitor (Any) (defaults to: params_lookup( 'monitor' , 'global' ))
  • monitor_tool (Any) (defaults to: params_lookup( 'monitor_tool' , 'global' ))
  • monitor_target (Any) (defaults to: params_lookup( 'monitor_target' , 'global' ))
  • puppi (Any) (defaults to: params_lookup( 'puppi' , 'global' ))
  • puppi_helper (Any) (defaults to: params_lookup( 'puppi_helper' , 'global' ))
  • debug (Any) (defaults to: params_lookup( 'debug' , 'global' ))
  • audit_only (Any) (defaults to: params_lookup( 'audit_only' , 'global' ))
  • package (Any) (defaults to: params_lookup( 'package' ))
  • service (Any) (defaults to: params_lookup( 'service' ))
  • service_status (Any) (defaults to: params_lookup( 'service_status' ))
  • process (Any) (defaults to: params_lookup( 'process' ))
  • process_args (Any) (defaults to: params_lookup( 'process_args' ))
  • process_user (Any) (defaults to: params_lookup( 'process_user' ))
  • config_dir (Any) (defaults to: params_lookup( 'config_dir' ))
  • config_file (Any) (defaults to: params_lookup( 'config_file' ))
  • config_file_mode (Any) (defaults to: params_lookup( 'config_file_mode' ))
  • config_file_owner (Any) (defaults to: params_lookup( 'config_file_owner' ))
  • config_file_group (Any) (defaults to: params_lookup( 'config_file_group' ))
  • config_file_init (Any) (defaults to: params_lookup( 'config_file_init' ))
  • pid_file (Any) (defaults to: params_lookup( 'pid_file' ))
  • data_dir (Any) (defaults to: params_lookup( 'data_dir' ))
  • log_dir (Any) (defaults to: params_lookup( 'log_dir' ))
  • log_file (Any) (defaults to: params_lookup( 'log_file' ))
  • manage_repos (Any) (defaults to: params_lookup( 'manage_repos' ))
  • enable_debian_repo_legacy (Any) (defaults to: params_lookup( 'enable_debian_repo_legacy' ))
  • template_settings_templates (Any) (defaults to: params_lookup( 'template_settings_templates' ))
  • template_commands_general (Any) (defaults to: params_lookup( 'template_commands_general' ))
  • template_commands_extra (Any) (defaults to: params_lookup( 'template_commands_extra' ))
  • template_commands_special (Any) (defaults to: params_lookup( 'template_commands_special' ))
  • template_settings_contacts (Any) (defaults to: params_lookup( 'template_settings_contacts' ))
  • template_settings_timeperiods (Any) (defaults to: params_lookup( 'template_settings_timeperiods' ))
  • template_hostgroups_all (Any) (defaults to: params_lookup( 'template_hostgroups_all' ))


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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'manifests/init.pp', line 212

class icinga (
  $extra_dir_source            = params_lookup( 'extra_dir_source' ),
  $services_hash               = params_lookup( 'services_hash' ),
  $hosts_hash                  = params_lookup( 'hosts_hash' ),
  $hostgroups_hash             = params_lookup( 'hostgroups_hash' ),
  $dependencies_class          = params_lookup( 'dependencies_class' ),
  $enable_icingaweb            = params_lookup( 'enable_icingaweb' ),
  $template_icingaweb          = params_lookup( 'template_icingaweb' ),
  $source_dir_icingaweb        = params_lookup( 'source_dir_icingaweb' ),
  $source_dir_purge_icingaweb  = params_lookup( 'source_dir_purge_icingaweb' ),
  $config_dir_icingaweb        = params_lookup( 'config_dir_icingaweb' ),
  $config_file_icingaweb       = params_lookup( 'config_file_icingaweb' ),
  $config_file_mode_icingaweb  = params_lookup( 'config_file_mode_icingaweb' ),
  $config_file_owner_icingaweb = params_lookup( 'config_file_owner_icingaweb' ),
  $config_file_group_icingaweb = params_lookup( 'config_file_group_icingaweb' ),
  $apache_icingaweb_config     = params_lookup( 'apache_icingaweb_config' ),
  $db_host_icingaweb           = params_lookup( 'db_host_icingaweb' ),
  $db_name_icingaweb           = params_lookup( 'db_name_icingaweb' ),
  $db_user_icingaweb           = params_lookup( 'db_user_icingaweb' ),
  $db_password_icingaweb       = params_lookup( 'db_password_icingaweb' ),
  $ido_pid_file                = params_lookup( 'ido_pid_file' ),
  $ido_socket_file             = params_lookup( 'ido_socket_file' ),
  $idoutilspackage             = params_lookup( 'idoutilspackage' ),
  $enable_idoutils             = params_lookup( 'enable_idoutils' ),
  $template_idoutils           = params_lookup( 'template_idoutils' ),
  $db_host_idoutils            = params_lookup( 'db_host_idoutils' ),
  $db_name_idoutils            = params_lookup( 'db_name_idoutils' ),
  $db_user_idoutils            = params_lookup( 'db_user_idoutils' ),
  $db_password_idoutils        = params_lookup( 'db_password_idoutils' ),
  $phpmysql_package            = params_lookup( 'phpmysql_package' ),
  $icingacgipackage            = params_lookup( 'icingacgipackage' ),
  $enable_icingacgi            = params_lookup( 'enable_icingacgi' ),
  $apache_icingacgi_config     = params_lookup( 'apache_icingacgi_config' ),
  $apache_icingacgi_target     = params_lookup( 'apache_icingacgi_target' ),
  $check_external_commands     = params_lookup( 'check_external_commands' ),
  $plugins                     = params_lookup( 'plugins' ),
  $use_ssl                     = params_lookup( 'use_ssl' ),
  $cachedir                    = params_lookup( 'cachedir' ),
  $temp_dir                    = params_lookup( 'temp_dir' ),
  $resourcefile                = params_lookup( 'resourcefile' ),
  $statusfile                  = params_lookup( 'statusfile' ),
  $commandfile                 = params_lookup( 'commandfile' ),
  $resultpath                  = params_lookup( 'resultpath' ),
  $retentionfile               = params_lookup( 'retentionfile' ),
  $p1file                      = params_lookup( 'p1file' ),
  $nrpepluginpackage           = params_lookup( 'nrpepluginpackage' ),
  $htpasswdfile                = params_lookup( 'htpasswdfile' ),
  $template_htpasswdfile       = params_lookup( 'template_htpasswdfile' ),
  $my_class                    = params_lookup( 'my_class' ),
  $source                      = params_lookup( 'source' ),
  $source_dir                  = params_lookup( 'source_dir' ),
  $source_dir_purge            = params_lookup( 'source_dir_purge' ),
  $template                    = params_lookup( 'template' ),
  $service_autorestart         = params_lookup( 'service_autorestart' , 'global' ),
  $options                     = params_lookup( 'options' ),
  $version                     = params_lookup( 'version' ),
  $absent                      = params_lookup( 'absent' ),
  $disable                     = params_lookup( 'disable' ),
  $disableboot                 = params_lookup( 'disableboot' ),
  $monitor                     = params_lookup( 'monitor' , 'global' ),
  $monitor_tool                = params_lookup( 'monitor_tool' , 'global' ),
  $monitor_target              = params_lookup( 'monitor_target' , 'global' ),
  $puppi                       = params_lookup( 'puppi' , 'global' ),
  $puppi_helper                = params_lookup( 'puppi_helper' , 'global' ),
  $debug                       = params_lookup( 'debug' , 'global' ),
  $audit_only                  = params_lookup( 'audit_only' , 'global' ),
  $package                     = params_lookup( 'package' ),
  $service                     = params_lookup( 'service' ),
  $service_status              = params_lookup( 'service_status' ),
  $process                     = params_lookup( 'process' ),
  $process_args                = params_lookup( 'process_args' ),
  $process_user                = params_lookup( 'process_user' ),
  $config_dir                  = params_lookup( 'config_dir' ),
  $config_file                 = params_lookup( 'config_file' ),
  $config_file_mode            = params_lookup( 'config_file_mode' ),
  $config_file_owner           = params_lookup( 'config_file_owner' ),
  $config_file_group           = params_lookup( 'config_file_group' ),
  $config_file_init            = params_lookup( 'config_file_init' ),
  $pid_file                    = params_lookup( 'pid_file' ),
  $data_dir                    = params_lookup( 'data_dir' ),
  $log_dir                     = params_lookup( 'log_dir' ),
  $log_file                    = params_lookup( 'log_file' ),
  $manage_repos                = params_lookup( 'manage_repos' ),
  $enable_debian_repo_legacy   = params_lookup( 'enable_debian_repo_legacy' ),
  $template_settings_templates = params_lookup( 'template_settings_templates' ),
  $template_commands_general   = params_lookup( 'template_commands_general' ),
  $template_commands_extra     = params_lookup( 'template_commands_extra' ),
  $template_commands_special   = params_lookup( 'template_commands_special' ),
  $template_settings_contacts  = params_lookup( 'template_settings_contacts' ),
  $template_settings_timeperiods = params_lookup( 'template_settings_timeperiods' ),
  $template_hostgroups_all     = params_lookup( 'template_hostgroups_all' )
  ) inherits icinga::params {

  $bool_enable_icingaweb=any2bool($enable_icingaweb)
  $bool_enable_icingacgi=any2bool($enable_icingacgi)
  $temp_bool_enable_idoutils=any2bool($enable_idoutils)
  $bool_enable_idoutils=$bool_enable_icingaweb ? {
    true  => true,
    false => $temp_bool_enable_idoutils,
  }

  $bool_source_dir_purge_icingaweb=any2bool($source_dir_purge_icingaweb)
  $bool_use_ssl=any2bool($use_ssl)
  $bool_check_external_commands=any2bool($check_external_commands)
  $bool_source_dir_purge=any2bool($source_dir_purge)
  $bool_service_autorestart=any2bool($service_autorestart)
  $bool_absent=any2bool($absent)
  $bool_disable=any2bool($disable)
  $bool_disableboot=any2bool($disableboot)
  $bool_monitor=any2bool($monitor)
  $bool_puppi=any2bool($puppi)
  $bool_debug=any2bool($debug)
  $bool_audit_only=any2bool($audit_only)
  $bool_manage_repos = any2bool($manage_repos)
  $customconfigdir = "${config_dir}/auto.d"

  if $enable_debian_repo_legacy == true and $bool_enable_icingaweb == true {
    $bool_enable_debian_repo_legacy = true
  } else {
    $bool_enable_debian_repo_legacy = false
  }

  ### Definition of some variables used in the module
  $manage_package = $icinga::bool_absent ? {
    true  => 'absent',
    false => $icinga::version,
  }

  $manage_service_enable = $icinga::bool_disableboot ? {
    true    => false,
    default => $icinga::bool_disable ? {
      true    => false,
      default => $icinga::bool_absent ? {
        true  => false,
        false => true,
      },
    },
  }

  $manage_service_ensure = $icinga::bool_disable ? {
    true    => 'stopped',
    default =>  $icinga::bool_absent ? {
      true    => 'stopped',
      default => 'running',
    },
  }

  $manage_service_autorestart = $icinga::bool_service_autorestart ? {
    true    => Service[icinga],
    false   => undef,
  }

  $manage_file = $icinga::bool_absent ? {
    true    => 'absent',
    default => 'present',
  }

  if $icinga::bool_absent == true
  or $icinga::bool_disable == true
  or $icinga::bool_disableboot == true {
    $manage_monitor = false
  } else {
    $manage_monitor = true
  }

  $manage_audit = $icinga::bool_audit_only ? {
    true  => 'all',
    false => undef,
  }

  $manage_file_replace = $icinga::bool_audit_only ? {
    true  => false,
    false => true,
  }

  $manage_file_source = $icinga::source ? {
    ''        => undef,
    default   => $icinga::source,
  }

  $manage_file_content = $icinga::template ? {
    ''        => undef,
    default   => template($icinga::template),
  }

  $manage_file_content_icingaweb = $icinga::template_icingaweb ? {
    ''        => undef,
    default   => template($icinga::template_icingaweb),
  }

  $manage_file_content_idoutils = template($icinga::template_idoutils)

  ### Managed resources
  package { 'nrpe-plugin':
    ensure  => $icinga::manage_package,
    name    => $icinga::nrpepluginpackage,
    require => Package['icinga'], # this has to be installed after icinga, to avoid the Recommend:nagios3 pulling in the wrong server
  }

  package { 'icinga':
    ensure  => $icinga::manage_package,
    name    => $icinga::package,
    require => Class['icinga::repository'],
  }

  service { 'icinga':
    ensure    => $icinga::manage_service_ensure,
    name      => $icinga::service,
    enable    => $icinga::manage_service_enable,
    hasstatus => $icinga::service_status,
    pattern   => $icinga::process,
    require   => [ Package['icinga'] , Class['icinga::skel'] ] ,
  }

  file { 'icinga.conf':
    ensure  => $icinga::manage_file,
    path    => $icinga::config_file,
    mode    => $icinga::config_file_mode,
    owner   => $icinga::config_file_owner,
    group   => $icinga::config_file_group,
    require => Package['icinga'],
    notify  => $icinga::manage_service_autorestart,
    source  => $icinga::manage_file_source,
    content => $icinga::manage_file_content,
    replace => $icinga::manage_file_replace,
    audit   => $icinga::manage_audit,
  }

  # The whole icinga configuration directory can be recursively overriden
  if $icinga::source_dir {
    file { 'icinga.dir':
      ensure  => directory,
      path    => $icinga::config_dir,
      require => Package['icinga'],
      notify  => $icinga::manage_service_autorestart,
      source  => $icinga::source_dir,
      recurse => true,
      purge   => $icinga::bool_source_dir_purge,
      replace => $icinga::manage_file_replace,
      audit   => $icinga::manage_audit,
    }
  }

  # Include configuration directories and files
  include icinga::skel
  include icinga::target
  # Collects all the stored configs regarding icinga
  # Host/Service Checks aggregation policy is based on $::icinga_filemode
  case $::icinga_filemode {
    'concat': {
      # One file per host with all the relevant services in auto.d/hosts
      # Concatenated with puppetlabs-concat
      include concat::setup
      Concat <<| tag == "icinga_check_${icinga::target::magic_tag}" |>>
      Concat::Fragment <<| tag == "icinga_check_${icinga::target::magic_tag}" |>>
    }
    'pupmod-concat': {
      # One file per host with all the relevant services in auto.d/hosts
      # Concatenated with onyxpoint-pupmod-concat
      Concat_build <<| tag == "icinga_check_${icinga::target::magic_tag}" |>>
      Concat_fragment <<| tag == "icinga_check_${icinga::target::magic_tag}" |>>
    }
    default: {
      # One file per host auto.d/hosts
      # One file per service auto.d/services
      File <<| tag == "icinga_check_${icinga::target::magic_tag}" |>>
    }
  }

  $magic_hostgroup = get_magicvar($::icinga_hostgrouplogic)
  if $::icinga_hostgrouplogic {
    #include concat::setup
    #Concat <<| tag == "icinga_hostgroup_${icinga::target::magic_tag}" |>>
    #Concat::Fragment <<| tag == "icinga_hostgroup_${icinga::target::magic_tag}" |>>
    include icinga::hostgroup_setup
    File <<| tag == "icinga_hostgroup_${icinga::target::magic_hostgroup}" |>>
  }

  ### Include custom class if $my_class is set
  if $icinga::my_class {
    include $icinga::my_class
  }
  
  if $icinga::dependencies_class != '' {
    include $icinga::dependencies_class
  }

  # Create resources from hashes, if present
  if $services_hash {
    create_resources('icinga::service_local', $services_hash)
  }

  if $hosts_hash {
    create_resources('icinga::host_local', $hosts_hash)
  }

  if $hostgroups_hash {
    create_resources('icinga::hostgroup_local', $hostgroups_hash)
  }


  ### Provide puppi data, if enabled ( puppi => true )
  if $icinga::bool_puppi == true {
    $classvars=get_class_args()
    puppi::ze { 'icinga':
      ensure    => $icinga::manage_file,
      variables => $classvars,
      helper    => $icinga::puppi_helper,
    }
  }

  if $::operatingsystem =~ /(?i:Debian|Ubuntu|Mint)/ {
    file{ 'icinga_service_config':
      path    => '/etc/default/icinga',
      content => template( 'icinga/debian_service_config.erb' )
    }
  }

  ### Service monitoring, if enabled ( monitor => true )
  if $icinga::bool_monitor == true {
    monitor::process { 'icinga_process':
      process  => $icinga::process,
      service  => $icinga::service,
      pidfile  => $icinga::pid_file,
      user     => $icinga::process_user,
      argument => $icinga::process_args,
      tool     => $icinga::monitor_tool,
      enable   => $icinga::manage_monitor,
    }
  }


  ### Debugging, if enabled ( debug => true )
  if $icinga::bool_debug == true {
    file { 'debug_icinga':
      ensure  => $icinga::manage_file,
      path    => "${settings::vardir}/debug-icinga",
      mode    => '0640',
      owner   => 'root',
      group   => 'root',
      content => inline_template('<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|path|timestamp|free|.*password.*|.*psk.*|.*key)/ }.to_yaml %>'),
    }
  }

  ### IDOUTILS Support
  if $icinga::bool_enable_idoutils == true {
    include icinga::idoutils
  }

  ### ICINGAWEB Installation
  if $icinga::bool_enable_icingaweb == true {
    include icinga::web
  }

  # The idoutils installer configures a database user that we
  # blatantly override. Hence this order definition
  if($icinga::bool_enable_icingaweb == true and $icinga::bool_enable_idoutils == true) {
    Class ['::icinga::idoutils'] -> Class ['::icinga::web']
  }

  ### ICINGACGI Installation
  if $icinga::bool_enable_icingacgi == true {
    include icinga::cgi
  }

  ### Adding www-data to group icinga.
  ### www-data needs permission to icinga.cmd when executing external commands.
  if $::operatingsystem =~ /(?i:Debian|Ubuntu|Mint)/ {
    user { 'www-data':
      groups  => 'nagios',
      require => [ Package['icinga'] ],
    }
  }

}