Defined Type: icingaweb2::module::monitoring::commandtransport

Defined in:
manifests/module/monitoring/commandtransport.pp

Summary

Manages commandtransport configuration for the monitoring module.

Overview

Parameters:

  • commandtransport (String[1]) (defaults to: $title)

    The name of the commandtransport.

  • transport (Enum['api', 'local']) (defaults to: 'api')

    The transport type you wish to use. Either ‘api` or `local`.

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

    Hostname/ip for the transport. Only needed for api transport.

  • port (Stdlib::Port) (defaults to: 5665)

    Port for the transport. Only needed for api transport.

  • username (Optional[String[1]]) (defaults to: undef)

    Username for the transport. Only needed for api transport.

  • password (Optional[Icinga::Secret]) (defaults to: undef)

    Password for the transport. Only needed for api transport.

  • path (Stdlib::Absolutepath) (defaults to: '/var/run/icinga2/cmd/icinga2.cmd')

    Path for the transport. Only needed for local transport.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'manifests/module/monitoring/commandtransport.pp', line 27

define icingaweb2::module::monitoring::commandtransport (
  String[1]                    $commandtransport = $title,
  Enum['api', 'local']         $transport        = 'api',
  Stdlib::Host                 $host             = 'localhost',
  Stdlib::Port                 $port             = 5665,
  Optional[String[1]]          $username         = undef,
  Optional[Icinga::Secret]     $password         = undef,
  Stdlib::Absolutepath         $path             = '/var/run/icinga2/cmd/icinga2.cmd',
) {
  $conf_dir        = $icingaweb2::globals::conf_dir
  $module_conf_dir = "${conf_dir}/modules/monitoring"

  case $transport {
    'api': {
      $commandtransport_settings = {
        'transport' => $transport,
        'host'      => $host,
        'port'      => $port,
        'username'  => $username,
        'password'  => unwrap($password),
      }
    }
    'local': {
      $commandtransport_settings = {
        'transport' => $transport,
        'path'      => $path,
      }
    }
    default: {
      fail('The transport type you provided is not supported')
    }
  }

  icingaweb2::inisection { "monitoring-commandtransport-${commandtransport}":
    section_name => $commandtransport,
    target       => "${module_conf_dir}/commandtransports.ini",
    settings     => delete_undef_values($commandtransport_settings),
  }
}