summaryrefslogtreecommitdiff
path: root/manifests/agent/config.pp
blob: 58e3b1e587d32d0b681906f180b6c9f72e754aa0 (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
class check_mk::agent::config (
  $ip_whitelist    = '',
  $port,
  $server_dir,
  $keydir,
  $authdir,
  $authfile        = undef,
  $use_cache,
  $user,
  $method          = 'xinetd',
  $generate_sshkey = false,
) {
  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 {
        if $authfile {
          # if authfile is overridden, pass it through
          check_mk::agent::generate_sshkey { 'check_mk_key':
            keydir   => $keydir,
            authdir  => $authdir,
            authfile => $authfile
          }
        } else {
          # otherwise don't
          check_mk::agent::generate_sshkey { 'check_mk_key':
            keydir  => $keydir,
            authdir => $authdir
          }
        }
      }

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