summaryrefslogtreecommitdiff
path: root/manifests/service/smtp.pp
blob: 14237a9e6deac5ab1bfe66d62ac287aae3468221 (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
# true:
#   - true   : check tls and plain connect *defualt*
#   - false : check plain connection only
# cert_days:
#   If tls is used add an additionl check
#   to check for validity for cert.
#   - 'absent' : do not execute that check
#   - INTEGER  : Minimum number of days a certificate
#                has to be valid. Default: 10
define nagios::service::smtp(
  $ensure = 'present',
  $host = 'absent',
  $port = '25',
  $tls = true,
  $cert_days = 10
){
  $real_host = $host ? {
    'absent' => $name,
     default => $host
  }

  nagios::service{
    "smtp_${name}_${port}":
      ensure => $ensure;
    "smtp_tls_${name}_${port}":
      ensure => $tls ? {
        true => $ensure,
        default => 'absent'
      };
    "smtp_tls_cert_${name}_${port}":
      ensure => $cert_days ? {
        'absent' => 'absent',
        default => $ensure
      };
  }

  if $ensure != 'absent' {
    Nagios::Service["smtp_${name}_${port}"]{
      check_command => "check_smtp!${real_host}!${port}",
    }
    Nagios::Service["smtp_tls_${name}_${port}"]{
      check_command => "check_smtp_tls!${real_host}!${port}",
    }
    if $cert_days != 'absent' {
      Nagios::Service["smtp_tls_cert_${name}_${port}"]{
        check_command => "check_smtp_cert!${real_host}!${port}!${cert_days}",
      }
    }
  }
}