summaryrefslogtreecommitdiff
path: root/manifests/service/http.pp
blob: 8fd5059f50f5b0f4f8d6f2cbb5242f91f66c45df (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
# ssl_mode:
#   - false: only check http
#   - true: check http and https
#   - force: http is permanent redirect to https
#   - only: check only https
define nagios::service::http(
    $ensure = present,
    $check_domain = 'absent',
    $check_url = '/',
    $check_code = 'OK',
    $use = 'generic-service',
    $ssl_mode = false
){
    $real_check_domain = $check_domain ? {
        'absent' => $name,
        default => $check_domain
    }
    case $ssl_mode {
        'force',true,'only': {
            nagios::service{"https_${name}_${check_code}":
                ensure => $ensure,
                use => $use,
                check_command => "check_https_url_regex!${real_check_domain}!${check_url}!'${check_code}'",
            }
            case $ssl_mode {
                'force': {
                    nagios::service{"httprd_${name}":
                        ensure => $ensure,
                        use => $use,
                        check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'",
                    }
                }
            }
        }
    }
    case $ssl_mode {
        false,true: {
            nagios::service{"http_${name}_${check_code}":
                ensure => $ensure,
                use => $use,
                check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'",
            }
        }
    }
}