From 05ac584cbf67f067da1f8d9bc39b093250c6fce8 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Thu, 18 Jul 2013 18:24:21 +0300 Subject: [PATCH] munin: Rewrote munin::plugin --- munin/manifests/init.pp | 95 +++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/munin/manifests/init.pp b/munin/manifests/init.pp index 29dd689..d6d46fd 100644 --- a/munin/manifests/init.pp +++ b/munin/manifests/init.pp @@ -143,76 +143,61 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") { # Plugin name to install. # $enable: # Set to false to disable plugin. +# $source: +# Source path for the plugin. # $config: -# Configuration file name associated with plugin. Defaults to none. +# Source path of plugin configuration file. Defaults to none. # # === Sample usage # -# munin::plugin { "vmware_vms": -# config => "vmware", +# munin::plugin { "nagios_multi_": +# source => "puppet:///files/munin/plugins/nagios_multi_", +# config => "puppet:///files/munin/plugins/nagios_multi_.conf", # } # -define munin::plugin($enable=true, $config="") { +define munin::plugin($enable=true, $source=undef, $config=undef) { if $enable == true { + if ! $source { + fail("Must define source parameter for Munin::Plugin[${name}]") + } + case $::operatingsystem { "openbsd": { - file { "/usr/local/libexec/munin/plugins/${name}": - ensure => present, - mode => "0755", - owner => "root", - group => "wheel", - source => [ "puppet:///files/munin/plugins/${name}", - "puppet:///modules/munin/plugins/${name}", ], - require => Package["munin-node"], - } - exec { "munin-enable-${name}": - command => "ln -s /usr/local/libexec/munin/plugins/${name} /etc/munin/plugins/${name}", - path => "/bin:/usr/bin:/sbin:/usr/sbin", - user => "root", - onlyif => [ "test ! -h /etc/munin/plugins/${name}", - "/usr/local/libexec/munin/plugins/${name} autoconf", ], - notify => Service["munin-node"], - require => File["/usr/local/libexec/munin/plugins/${name}"], - } + $plugindir = "/usr/local/libexec/munin/plugins" } default: { - file { "/usr/share/munin/plugins/${name}": - ensure => present, - mode => "0755", - owner => "root", - group => "root", - source => [ "puppet:///files/munin/plugins/${name}", - "puppet:///modules/munin/plugins/${name}", ], - require => Package["munin-node"], - } - exec { "munin-enable-${name}": - command => "ln -s /usr/share/munin/plugins/${name} /etc/munin/plugins/${name}", - path => "/bin:/usr/bin:/sbin:/usr/sbin", - user => "root", - onlyif => [ "test ! -h /etc/munin/plugins/${name}", - "/usr/share/munin/plugins/${name} autoconf", ], - notify => Service["munin-node"], - require => File["/usr/share/munin/plugins/${name}"], - } + $plugindir = "/usr/share/munin/plugins" } } - if $config { - file { "/etc/munin/plugin-conf.d/${config}": - ensure => present, - mode => "0644", - owner => "root", - group => $::operatingsystem ? { - "openbsd" => "wheel", - default => "root", - }, - source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}", - "puppet:///files/munin/plugin-conf/${config}", - "puppet:///modules/munin/plugin-conf/${config}", ], - notify => Service["munin-node"], - before => Exec["munin-enable-name"], - } + file { "${plugindir}/${name}": + ensure => present, + mode => "0755", + owner => "root", + group => $::operatingsystem ? { + "openbsd" => "wheel", + default => "root", + }, + source => $source, + notify => Exec["munin-node-configure"], + require => Package["munin-node"], + } + + file { "/etc/munin/plugin-conf.d/${name}": + ensure => $config ? { + undef => absent, + default => present, + }, + mode => "0644", + owner => "root", + group => $::operatingsystem ? { + "openbsd" => "wheel", + default => "root", + }, + source => $config, + notify => Exec["munin-node-configure"], + require => Package["munin-node"], } } else { file { "/etc/munin/plugin-conf.d/${name}":