Puppet Class: icinga::target

Defined in:
manifests/target.pp

Overview

Class: icinga::target

Basic host target class Include it on nodes to be monitored by icinga

Usage: include icinga::target

Parameters:

  • host_template (Any) (defaults to: 'generic-host')
  • host_parent (Any) (defaults to: '')
  • automatic_host (Any) (defaults to: true)
  • automatic_services (Any) (defaults to: true)
  • baseservices_template (Any) (defaults to: $::icinga_baseservices_template)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
# File 'manifests/target.pp', line 10

class icinga::target ($host_template = 'generic-host', $host_parent = '', $automatic_host = true, $automatic_services = true, $baseservices_template = $::icinga_baseservices_template) {
  # This variable defines where icinga automatically generated
  # files are places. This MUST be the same of $::icinga::customconfigdir
  # HINT: Do not mess with default path names...

  $customconfigdir = $::icinga_customconfigdir ? {
    ''      => '/etc/icinga/auto.d',
    default => $::icinga_customconfigdir,
  }

  $bool_automatic_host = any2bool($automatic_host)
  $bool_automatic_services = any2bool($automatic_services)

  $hostgroupsbuilddir = '/etc/icinga/hostgroups_build'

  # TODO: Find a smarter solution that doesn't require TopScope Variables
  $magic_tag = get_magicvar($::icinga_grouplogic)

  # TODO: Find a smarter solution that doesn't require TopScope Variables
  $magic_hostgroup = get_magicvar($::icinga_hostgrouplogic)

  if ($bool_automatic_host) {
    icinga::host { $::fqdn:
      use         => $host_template,
      host_parent => $host_parent
    }
  }

  $real_baseservices_template = $baseservices_template ? {
    undef   => '',
    default => $baseservices_template,
  }

  if ($bool_automatic_services) {
    icinga::baseservices { $::fqdn:
      use      => 'generic-service',
      template => $real_baseservices_template,
    }
  }

  # TODO: Make this work with nagios::plugins
  # include icinga::plugins

  # Automatic hostgroup management
  if $::icinga_hostgrouplogic {
    icinga::hostgroup { $::fqdn: hostgroup => $magic_hostgroup, }
  }
}