diff options
author | micah <micah@muck.riseup.net> | 2013-03-20 18:25:28 -0400 |
---|---|---|
committer | micah <micah@muck.riseup.net> | 2013-03-20 18:25:28 -0400 |
commit | c9748747c5c755443d80445a9a6c3f5d2ab3bc7f (patch) | |
tree | 65887003b9bceefd7a6ba3e3692b9a6f08373304 /manifests/plugin.pp | |
parent | 149a78e7a8465da97f8ea267cd6a75e3bcdefe4d (diff) | |
parent | f79f662bedbbd75c7e2022da282ba48c1b323e90 (diff) |
Merge branch 'immerda/master'
Conflicts:
files/plugins/xen-cpu
templates/munin-node.conf.Debian.squeeze
Diffstat (limited to 'manifests/plugin.pp')
-rw-r--r-- | manifests/plugin.pp | 102 |
1 files changed, 46 insertions, 56 deletions
diff --git a/manifests/plugin.pp b/manifests/plugin.pp index d243b66..ffe5452 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,67 +1,57 @@ -# plugin.pp - configure a specific munin plugin -# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> -# See LICENSE for the full license granted to you. -# adapted and improved by admin(at)immerda.ch - -### defines - +# configure a specific munin plugin define munin::plugin ( - $ensure = "present", - $script_path_in = '', - $config = '' ) -{ - include munin::plugin::scriptpaths - $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in } + $ensure = 'present', + $script_path_in = '', + $config = '' +) { + include munin::plugin::scriptpaths + $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in } - $plugin_src = $ensure ? { "present" => $name, default => $ensure } - $plugin = "/etc/munin/plugins/$name" - $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf" - - include munin::plugins::setup - case $ensure { - "absent": { - file { $plugin: ensure => absent, } - } - default: { - case $kernel { - openbsd: { $basic_require = File['/var/run/munin'] } - default: { $basic_require = Package['munin-node'] } - } - if $require { - $real_require = [ $require, $basic_require ] - } else { - $real_require = $basic_require - } - file { $plugin: - ensure => "${real_script_path}/${plugin_src}", - require => $real_require, - notify => Service['munin-node']; - } + $plugin_src = $ensure ? { 'present' => $name, default => $ensure } + $plugin = "/etc/munin/plugins/${name}" + $plugin_conf = "/etc/munin/plugin-conf.d/${name}.conf" + include munin::plugins::setup + case $ensure { + 'absent': { + file { $plugin: ensure => absent, } + } + default: { + $dep = $::kernel ? { + OpenBSD => File['/var/run/munin'], + default => Package['munin-node'] + } + file { $plugin: + ensure => "${real_script_path}/${plugin_src}", + require => $dep, + notify => Service['munin-node']; + } + if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ + File[$plugin]{ + seltype => 'munin_etc_t', } + } + } + } + case $config { + '': { + file { $plugin_conf: ensure => absent } } - case $config { - '': { - file { $plugin_conf: ensure => absent } + default: { + case $ensure { + absent: { + file { $plugin_conf: ensure => absent } } default: { - case $ensure { - absent: { - file { $plugin_conf: ensure => absent } - } - default: { - file { $plugin_conf: - content => "[${name}]\n$config\n", - mode => 0640, owner => root, group => 0, - } - if $require { - File[$plugin_conf]{ - require +> $require, - } - } - } - } + file { $plugin_conf: + content => "[${name}]\n${config}\n", + owner => root, + group => 0, + mode => '0640', + } } + } } + } } |