summaryrefslogtreecommitdiff
path: root/manifests/plugin/deploy.pp
blob: 2ffd92e278e1a8b1ed13ddab7258f16d8410feb3 (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
# deploy and register a munin plugin
define munin::plugin::deploy(
  $ensure   = 'present',
  $source   = '',
  $config   = '',
  $seltype  = 'munin_unconfined_plugin_exec_t',
  $register = true,
) {
  $plugin_src = $ensure ? {
    'present' => $name,
    'absent'  => $name,
    default   => $ensure
  }
  $real_source = $source ? {
    ''      =>  "munin/plugins/${plugin_src}",
    default => $source
  }
  include munin::plugin::scriptpaths
  file { "munin_plugin_${name}":
    path    => "${munin::plugin::scriptpaths::script_path}/${name}",
    source  => "puppet:///modules/${real_source}",
    owner   => root,
    group   => 0,
    mode    => '0755';
  }

  if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::operatingsystemmajrelease > '5')){
    File["munin_plugin_${name}"]{
      seltype => $seltype,
    }
  }

  case $::kernel {
    openbsd: { $basic_require = File['/var/run/munin'] }
    default: { $basic_require = Package['munin-node'] }
  }
  File["munin_plugin_${name}"]{
    require => $basic_require,
  }

  # register the plugin if required
  if ($register) {
    munin::plugin{$name:
      ensure => $ensure,
      config => $config
    }
  }
}