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
57
58
59
60
61
62
|
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],
})
}
$service_group = "${::profile::monitoring::params::service_local[host_name]}-servicegroup"
ensure_resource("nagios_servicegroup", $service_group, {
target => $::profile::monitoring::params::services_for_master,
})
[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"],
servicegroups => $service_group,
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
}
}
}
|