aboutsummaryrefslogtreecommitdiff
path: root/modules/profile/manifests/monitoring/local_service.pp
blob: 1f975f03c26d91038ad4c3341e976a15ff0f1d73 (plain) (blame)
1
2
3
4
5
6
7
8
9
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
define profile::monitoring::local_service (
  Optional[Hash] $sudos  = {},
  Optional[Hash] $common = {},
  Optional[Hash] $master = {},
  Optional[Hash] $local  = {},
) {
  include profile::monitoring::params

  $service_description = $title

  Nagios_service {
    ensure  => "present",
    owner   => "naemon",
    group   => "naemon",
    notify  => Service["naemon"],
    before  => Service["naemon"],
    require => File["/etc/naemon"],
  }

  $sudos.each |$sudo_name, $content| {
    ensure_resource("sudo::conf", $sudo_name, {
      content => $content,
      before  => Nagios_service[$service_description],
    })
  }

  [true, false].each |$services_for_master| {
    if $services_for_master {
      $default_local = {
        mode           => "0644",
        target         => $::profile::monitoring::params::services_for_master,
        check_interval => $::profile::monitoring::params::service_local["check_interval"],
        retry_interval => $::profile::monitoring::params::service_local["retry_interval"],
        host_name      => $::profile::monitoring::params::service_local["host_name"],
        use            => $::profile::monitoring::params::service_types["passive"],
        notify         => [],
      }
      $t = "master - "
      $services_key = $master
    } else {
      $default_local = merge(
        $::profile::monitoring::params::service_local,
        { target => $::profile::monitoring::params::objects }
      )
      $t = ""
      $services_key = $local
    }

    $hash = merge($default_local, $common, $services_key)

    nagios_service { "$t$service_description":
      service_description => $service_description,
      *                   => $hash
    }
  }
}