summaryrefslogtreecommitdiff
path: root/puppet/modules/check_mk/manifests/agent/config.pp
blob: 8ee5f1850a9c0e45d06a2656e3d5f142b84da9c3 (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
class check_mk::agent::config (
  $ip_whitelist    = '',
  $port,
  $server_dir,
  $keydir,
  $authdir,
  $authfile        = undef,
  $use_cache,
  $user,
  $method          = 'xinetd',
  $generate_sshkey = false,
  $sshuser         = undef,
  $hostname        = $::fqdn
) {
  if $use_cache {
    $server = "${server_dir}/check_mk_caching_agent"
  } else {
    $server = "${server_dir}/check_mk_agent"
  }

  case $method {
    'xinetd': {
      if $ip_whitelist {
        $only_from = join($ip_whitelist, ' ')
      } else {
        $only_from = undef
      }

      file { '/etc/xinetd.d/check_mk':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('check_mk/agent/check_mk.erb'),
        require => Package['check_mk-agent','check_mk-agent-logwatch'],
        notify  => Class['check_mk::agent::service'],
      }
    }

    'ssh': {
      if $generate_sshkey {
        check_mk::agent::generate_sshkey { "check_mk_key_${hostname}":
          keydir   => $keydir,
          authdir  => $authdir,
          authfile => $authfile,
          sshuser  => $sshuser,
          hostname => $hostname
        }
      }

      # make sure the xinetd method is not configured
      file { '/etc/xinetd.d/check_mk':
        ensure  => absent;
      }
    }

    default : {}
  }
}