From aaf55c9ebfa0e34f63b2ca3c2b660e1d164026dd Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 6 May 2013 18:13:12 +0200 Subject: lintify --- manifests/plugin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/plugin.pp') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index ffe5452..60af877 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -26,7 +26,7 @@ define munin::plugin ( require => $dep, notify => Service['munin-node']; } - if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ + if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File[$plugin]{ seltype => 'munin_etc_t', } -- cgit v1.2.3 From 3064a5d5a6251f84cf4d115be1711266faf7ed13 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 3 Nov 2013 18:21:57 +0100 Subject: fix #26 - do not manage files of a plugin if it should be absent The directories are recursively managed and will purge these files anyway and trigger a proper restart. Like that we can safe a few resources in our catalog. --- manifests/plugin.pp | 74 ++++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 43 deletions(-) (limited to 'manifests/plugin.pp') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 60af877..ef82f90 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 $::lsbmajdistrelease != '5')){ + File["/etc/munin/plugins/${name}"]{ + seltype => 'munin_etc_t', } - if (str2bool($::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 $config != '' { + file { "/etc/munin/plugin-conf.d/${name}.conf": + content => "[${name}]\n${config}\n", + owner => root, + group => 0, + mode => '0640', } } } -- cgit v1.2.3 From 88d197da8cedd5d711db043995f725ebe66b6ed6 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 13 Jun 2014 12:25:48 +0200 Subject: implement #38 - allow config to be an array --- manifests/plugin.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests/plugin.pp') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index ef82f90..37d0077 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -32,9 +32,9 @@ define munin::plugin ( seltype => 'munin_etc_t', } } - if $config != '' { + if !empty($config) { file { "/etc/munin/plugin-conf.d/${name}.conf": - content => "[${name}]\n${config}\n", + content => inline_template("[<%= @name %>]\n<%= Array(@config).join(\"\n\") %>\n"), owner => root, group => 0, mode => '0640', -- cgit v1.2.3 From 39eb7ac31ad7f1fc16c37c42823fb1860c1f09ba Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 9 Jul 2014 23:12:27 +0200 Subject: get rid off lsb facts - who runs sarge? --- manifests/plugin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/plugin.pp') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 37d0077..50b861b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -27,7 +27,7 @@ define munin::plugin ( target =>"${real_script_path}/${plugin_src}", notify => Service['munin-node']; } - if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ + if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::operatingsystemmajrelease != '5')){ File["/etc/munin/plugins/${name}"]{ seltype => 'munin_etc_t', } -- cgit v1.2.3