diff options
author | Gabriel Filion <gabster@lelutin.ca> | 2014-12-13 09:34:56 -0500 |
---|---|---|
committer | Gabriel Filion <gabster@lelutin.ca> | 2014-12-13 10:21:25 -0500 |
commit | 48272434978f95c70e34aebe9ce188157f8f935e (patch) | |
tree | 8c940d891cbcba026d56cf8ed2935361debc44fd /manifests/plugin.pp | |
parent | 7e03247a9e219fe8e57d544957eb06e305e69fc1 (diff) | |
parent | 27c9a5dbc2083dcc20d059008702dd3f75382bcc (diff) |
Merge remote-tracking branch 'immerda/master' into merge_immerda
Conflicts:
manifests/plugins/interfaces.pp
$real_ifs was changed on master and we'd like to keep that change
$ifs was changed to use the prefix() function and we'd like to keep that
change.
Diffstat (limited to 'manifests/plugin.pp')
-rw-r--r-- | manifests/plugin.pp | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/manifests/plugin.pp b/manifests/plugin.pp index ffe5452..50b861b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,55 +1,43 @@ # configure a specific munin plugin +# +# We only manage the plugin if it is not set to absent. +# A plugin (or its config) that should be removed should +# be purged by the recursively managed plugins- or +# config-directory. So we can safe a few resources being +# managed. define munin::plugin ( $ensure = 'present', $script_path_in = '', - $config = '' + $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" + if $ensure != 'absent' { + include munin::plugin::scriptpaths + include munin::plugins::setup + $real_script_path = $script_path_in ? { + '' => $munin::plugin::scriptpaths::script_path, + default => $script_path_in + } + $plugin_src = $ensure ? { + 'present' => $name, + default => $ensure + } - include munin::plugins::setup - case $ensure { - 'absent': { - file { $plugin: ensure => absent, } + file { "/etc/munin/plugins/${name}": + ensure => link, + target =>"${real_script_path}/${plugin_src}", + notify => Service['munin-node']; } - 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 (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::operatingsystemmajrelease != '5')){ + File["/etc/munin/plugins/${name}"]{ + seltype => 'munin_etc_t', } - 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 } } - default: { - case $ensure { - absent: { - file { $plugin_conf: ensure => absent } - } - default: { - file { $plugin_conf: - content => "[${name}]\n${config}\n", - owner => root, - group => 0, - mode => '0640', - } - } + if !empty($config) { + file { "/etc/munin/plugin-conf.d/${name}.conf": + content => inline_template("[<%= @name %>]\n<%= Array(@config).join(\"\n\") %>\n"), + owner => root, + group => 0, + mode => '0640', } } } |