Puppet Class: checkmk::install::agent

Defined in:
manifests/install/agent.pp

Summary

Installs CheckMK Agent

Overview



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
# File 'manifests/install/agent.pp', line 2

class checkmk::install::agent {
  case $facts['os']['family'] {
    'Debian': {
      agent_package { '/tmp/check-mk-agent.deb':
        ensure       => $checkmk::agent_package_ensure,
        url          => "${checkmk::agent_download_protocol}://${checkmk::agent_download_host}",
        bearer_token => $checkmk::automation_user_password,
        site_name    => $checkmk::site_name,
        os_type      => 'linux_deb',
      }

      package { 'check-mk-agent':
        ensure   => installed,
        provider => 'apt',
        source   => '/tmp/check-mk-agent.deb',
        require  => Agent_package['/tmp/check-mk-agent.deb'],
      }

      create_host { $checkmk::hostname:
        ensure       => present,
        url          => "${checkmk::agent_download_protocol}://${checkmk::agent_download_host}",
        bearer_token => $checkmk::automation_user_password,
        site_name    => $checkmk::site_name,
        folder       => $checkmk::agent_folder,
        require      => Package['check-mk-agent'],
      }
      Package['check-mk-agent'] -> Create_host[$facts['fqdn']]

      $registration_server = checkmk::registration_server(
        "${checkmk::agent_download_protocol}://${checkmk::agent_download_host}",
        $checkmk::site_name,
      )

      exec { 'register checkmk agent':
        command => "/usr/bin/cmk-agent-ctl register --hostname ${checkmk::hostname} --server ${registration_server} --site ${checkmk::site_name} --user automation --password ${checkmk::automation_user_password} --trust-cert",
        require => [Package['check-mk-agent'], Create_host[$facts['fqdn']]],
        onlyif  => "/usr/bin/cmk-agent-ctl status --json | grep -q '\"connections\":\\[\\]'",
      }
    }
    default: {
      fail('Unsupported OS family')
    }
  }
}