summaryrefslogtreecommitdiff
path: root/manifests/service.pp
blob: 3e732b75d2dedefe97c073c309df8850f58a663b (plain)
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
63
64
65
66
67
68
69
define nagios::service (
    $ensure = present,
    $host_name = $fqdn,
    $check_command,
    $check_period = '',
    $normal_check_interval = '',
    $retry_check_interval = '',
    $max_check_attempts = '',
    $notification_interval = '',
    $notification_period = '',
    $notification_options = '',
    $contact_groups = '',
    $use = 'absent',
    $service_description = 'absent' )
{

    # TODO: this resource should normally accept all nagios_host parameters

    $real_name = "${hostname}_${name}"

    @@nagios_service { "${real_name}":
        ensure => $ensure,
        check_command => $check_command,
        host_name => $host_name,
        notify => Service[nagios],
    }

    if ($check_period != '') {
        Nagios_service["${real_name}"] { check_period => $check_period }
    }

    if ($normal_check_interval != '') {
        Nagios_service["${real_name}"] { normal_check_interval => $normal_check_interval }
    }

    if ($retry_check_interval != '') {
        Nagios_service["${real_name}"] { retry_check_interval => $retry_check_interval }
    }

    if ($max_check_attempts != '') {
        Nagios_service["${real_name}"] { max_check_attempts => $max_check_attempts }
    }

    if ($notification_interval != '') {
        Nagios_service["${real_name}"] { notification_interval => $notification_interval }
    }

    if ($notification_period != '') {
        Nagios_service["${real_name}"] { notification_period => $notification_period }
    }

    if ($notification_options != '') {
        Nagios_service["${real_name}"] { notification_options => $notification_options }
    }

    if ($use == 'absent') {
        Nagios_service["${real_name}"] { use => 'generic-service' }
    } else {
        Nagios_service["${real_name}"] { use => $use }
    }

    if ($service_description == 'absent') {
        Nagios_service["${real_name}"] { service_description => $name }
    } else {
        Nagios_service["${real_name}"] { service_description => $service_description }
    }

}