summaryrefslogtreecommitdiff
path: root/manifests/agent.pp
blob: 505db6458c2a8c21a4d4194c304e6ab075fb2d0b (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
70
71
72
73
74
75
76
77
78
79
80
81
82
class check_mk::agent (
  $filestore    = undef,
  $host_tags    = undef,
  $ip_whitelist = undef,
  $port         = '6556',
  $server_dir   = '/usr/bin',
  $keydir       = '/omd/sites/monitoring',
  $authdir      = '/omd/sites/monitoring',
  $authfile     = undef,
  $use_cache    = false,
  $user         = 'root',
  $version      = undef,
  $workspace    = '/root/check_mk',
  $agent_package_name           = 'check_mk-agent',
  $agent_logwatch_package_name  = 'check_mk-agent-logwatch',
  $method                       = 'xinetd',
  $generate_sshkey              = false,
  $use_ssh_tag                  = 'ssh',
  $register_agent               = true
) {

  case $method {
    'xinetd': {
      $tags = $host_tags
      include check_mk::agent::service
    }
    'ssh': {
      if ( $host_tags != '' ) {
        $tags = "${host_tags}|${use_ssh_tag}"
      } else {
        $tags = $use_ssh_tag
      }
    }
    default: {}
  }

  class { 'check_mk::agent::install':
    version                     => $version,
    filestore                   => $filestore,
    workspace                   => $workspace,
    agent_package_name          => $agent_package_name,
    agent_logwatch_package_name => $agent_logwatch_package_name,
    method                      => $method
  }

  if $authfile {
    # if authfile is set, pass it though
    class { 'check_mk::agent::config':
      ip_whitelist       => $ip_whitelist,
      port               => $port,
      server_dir         => $server_dir,
      keydir             => $keydir,
      authdir            => $authdir,
      authfile           => $authfile,
      use_cache          => $use_cache,
      user               => $user,
      method             => $method,
      generate_sshkey    => $generate_sshkey,
      require            => Class['check_mk::agent::install'],
    }
  } else {
    # otherwise don't
    class { 'check_mk::agent::config':
      ip_whitelist       => $ip_whitelist,
      port               => $port,
      server_dir         => $server_dir,
      keydir             => $keydir,
      authdir            => $authdir,
      use_cache          => $use_cache,
      user               => $user,
      method             => $method,
      generate_sshkey    => $generate_sshkey,
      require            => Class['check_mk::agent::install'],
    }
  }

  if ( $register_agent ) {
    class { 'check_mk::agent::register':
      host_tags => $tags,
    }
  }
}