Puppet Class: icingaweb2::module::monitoring

Defined in:
manifests/module/monitoring.pp

Overview

Requirements:

  • IDO feature in Icinga 2 (MySQL or PostgreSQL)
  • ApiUser object in Icinga 2 with proper permissions

    class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_type => 'mysql', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', commandtransports => { icinga2 => { transport => 'api', username => 'icingaweb2', password => 'supersecret', } } }

Examples:

This module is mandatory for almost every setup. It connects your Icinga Web interface to the Icinga 2 core. Current and history information are queried through the IDO database. Actions such as Check Now, Set Downtime or Acknowledge are send to the Icinga 2 API.

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Enable or disable module.

  • protected_customvars (Variant[String, Array[String]]) (defaults to: ['*pw*', '*pass*', 'community'])

    Custom variables in Icinga 2 may contain sensible information. Set patterns for custom variables that should be hidden in the web interface.

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

    Type of your IDO database. Either mysql or pgsql.

  • ido_host (Optional[Stdlib::Host]) (defaults to: undef)

    Hostname of the IDO database.

  • ido_port (Stdlib::Port) (defaults to: 3306)

    Port of the IDO database.

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

    Name of the IDO database.

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

    Username for IDO DB connection.

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

    Password for IDO DB connection.

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

    The character set to use for the database connection.

  • commandtransports (Hash) (defaults to: {})

    A hash of command transports.



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

class icingaweb2::module::monitoring(
  Enum['absent', 'present']      $ensure               = 'present',
  Variant[String, Array[String]] $protected_customvars = ['*pw*', '*pass*', 'community'],
  Enum['mysql', 'pgsql']         $ido_type             = 'mysql',
  Optional[Stdlib::Host]         $ido_host             = undef,
  Stdlib::Port                   $ido_port             = 3306,
  Optional[String]               $ido_db_name          = undef,
  Optional[String]               $ido_db_username      = undef,
  Optional[Icingaweb2::Secret]   $ido_db_password      = undef,
  Optional[String]               $ido_db_charset       = undef,
  Hash                           $commandtransports    = {},
) {

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

  case $::osfamily {
    'Debian': {
      $install_method = 'package'
      $package_name   = 'icingaweb2-module-monitoring'
    }
    default: {
      $install_method = 'none'
      $package_name   = undef
    }
  }

  icingaweb2::config::resource { 'icingaweb2-module-monitoring':
    type        => 'db',
    db_type     => $ido_type,
    host        => $ido_host,
    port        => $ido_port,
    db_name     => $ido_db_name,
    db_username => $ido_db_username,
    db_password => $ido_db_password,
    db_charset  => $ido_db_charset,
  }

  $backend_settings = {
    'type'     => 'ido',
    'resource' => 'icingaweb2-module-monitoring',
  }

  $security_settings = {
    'protected_customvars' => $protected_customvars ? {
      String        => $protected_customvars,
      Array[String] => join($protected_customvars, ','),
    }
  }

  $settings = {
    'module-monitoring-backends' => {
      'section_name' => 'backends',
      'target'       => "${module_conf_dir}/backends.ini",
      'settings'     => delete_undef_values($backend_settings)
    },
    'module-monitoring-security' => {
      'section_name' => 'security',
      'target'       => "${module_conf_dir}/config.ini",
      'settings'     => delete_undef_values($security_settings)
    }
  }

  create_resources('icingaweb2::module::monitoring::commandtransport', $commandtransports)

  icingaweb2::module { 'monitoring':
    ensure         => $ensure,
    install_method => $install_method,
    package_name   => $package_name,
    settings       => $settings,
  }

}