]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/profile/manifests/monitoring/local_service.pp
Merge branch 'monitoring' into dev
[perso/Immae/Projets/Puppet.git] / modules / profile / manifests / monitoring / local_service.pp
1 define profile::monitoring::local_service (
2 Optional[Hash] $sudos = {},
3 Optional[Hash] $common = {},
4 Optional[Hash] $master = {},
5 Optional[Hash] $local = {},
6 ) {
7 include profile::monitoring::params
8
9 $service_description = $title
10
11 Nagios_service {
12 ensure => "present",
13 owner => "naemon",
14 group => "naemon",
15 notify => Service["naemon"],
16 before => Service["naemon"],
17 require => File["/etc/naemon"],
18 }
19
20 $sudos.each |$sudo_name, $content| {
21 ensure_resource("sudo::conf", $sudo_name, {
22 content => $content,
23 before => Nagios_service[$service_description],
24 })
25 }
26
27 [true, false].each |$services_for_master| {
28 if $services_for_master {
29 $default_local = {
30 mode => "0644",
31 target => $::profile::monitoring::params::services_for_master,
32 check_interval => $::profile::monitoring::params::service_local["check_interval"],
33 retry_interval => $::profile::monitoring::params::service_local["retry_interval"],
34 host_name => $::profile::monitoring::params::service_local["host_name"],
35 use => $::profile::monitoring::params::service_types["passive"],
36 notify => [],
37 }
38 $t = "master - "
39 $services_key = $master
40 } else {
41 $default_local = merge(
42 $::profile::monitoring::params::service_local,
43 { target => $::profile::monitoring::params::objects }
44 )
45 $t = ""
46 $services_key = $local
47 }
48
49 $hash = merge($default_local, $common, $services_key)
50
51 nagios_service { "$t$service_description":
52 service_description => $service_description,
53 * => $hash
54 }
55 }
56 }