summaryrefslogtreecommitdiff
path: root/manifests/agent/install.pp
blob: 5c0b56efdc6d1c23a1e3de1456c802e6548ce5d2 (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
class check_mk::agent::install (
  $version = '',
  $filestore = '',
  $workspace,
  $agent_package_name,
  $agent_logwatch_package_name,
  $method = 'xinetd',
) {
  if $method == 'xinetd' {
    if ! defined($require_method) {
      package { 'xinetd':
        ensure => latest,
      }
    }
    $require_method = 'Package[\'xinetd\']'
  } else {
    $require_method = undef
  }

  if $filestore {
    if ! defined(File[$workspace]) {
      file { $workspace:
        ensure => directory,
      }
    }
    file { "${workspace}/check_mk-agent-${version}.noarch.rpm":
      ensure  => latest,
      source  => "${filestore}/check_mk-agent-${version}.noarch.rpm",
      require => $require_method,
    }
    file { "${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm":
      ensure  => latest,
      source  => "${filestore}/check_mk-agent-logwatch-${version}.noarch.rpm",
      require => $require_method,
    }
    package { 'check_mk-agent':
      ensure   => latest,
      provider => 'rpm',
      source   => "${workspace}/check_mk-agent-${version}.noarch.rpm",
      require  => File["${workspace}/check_mk-agent-${version}.noarch.rpm"],
    }
    package { 'check_mk-agent-logwatch':
      ensure   => latest,
      provider => 'rpm',
      source   => "${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm",
      require  => [
        File["${workspace}/check_mk-agent-logwatch-${version}.noarch.rpm"],
        Package['check_mk-agent'],
      ],
    }
  }
  else {
    if $version {
      $agent_package_version = $version
    } else {
      $agent_package_version = latest
    }

    package { 'check_mk-agent':
      ensure  => $agent_package_version,
      name    => $agent_package_name,
      require => $require_method,
    }
    package { 'check_mk-agent-logwatch':
      ensure  => $agent_package_version,
      name    => $agent_logwatch_package_name,
      require => Package['check_mk-agent'],
    }
  }
}