summaryrefslogtreecommitdiff
path: root/manifests/plugin/deploy.pp
blob: 768159099d1ffc20329381ab3a30bde57adaa364 (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
# deploy a specific plugin
define nagios::plugin::deploy(
  $source = '',
  $ensure = 'present',
  $config = '',
  $require_package = 'nagios-plugins'
) {
  $plugin_src = $ensure ? {
    'present' => $name,
    'absent' => $name,
    default => $ensure
  }
  $real_source = $source ? {
    ''  =>  "nagios/plugins/${plugin_src}",
    default => $source
  }

  if !defined(Package[$require_package]) {
    package { $require_package:
      ensure => installed,
      tag    => 'nagios::plugin::deploy::package';
    }
  }

  include ::nagios::plugin::scriptpaths
  file{"nagios_plugin_${name}":
    path    => "${nagios::plugin::scriptpaths::script_path}/${name}",
    source  => "puppet:///modules/${real_source}",
    require => Package[$require_package],
    tag     => 'nagios::plugin::deploy::file',
    owner   => root,
    group   => 0,
    mode    => '0755';
  }

  # register the plugin
  nagios::plugin{$name:
    ensure  => $ensure,
    require => Package['nagios-plugins']
  }
}