diff --git a/munin/manifests/init.pp b/munin/manifests/init.pp index ec0894d..ab3a893 100644 --- a/munin/manifests/init.pp +++ b/munin/manifests/init.pp @@ -141,6 +141,8 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") { # # $name: # Plugin name to install. +# $enable: +# Set to false to disable plugin. # $config: # Configuration file name associated with plugin. Defaults to none. # @@ -150,95 +152,82 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") { # config => "vmware", # } # -define munin::plugin($config = "") { +define munin::plugin($enable=true, $config="") { - case $::operatingsystem { - OpenBSD: { - file { "/usr/local/libexec/munin/plugins/${name}": - ensure => present, - source => "puppet:///modules/munin/plugins/${name}", - owner => "root", - group => "wheel", - mode => "0755", - require => Package["munin-node"], + if $enable == true { + 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}"], + } + } + 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}"], + } } } - default: { - file { "/usr/share/munin/plugins/${name}": + + if $config { + file { "/etc/munin/plugin-conf.d/${config}": ensure => present, - source => "puppet:///modules/munin/plugins/${name}", + mode => "0644", owner => "root", - group => "root", - mode => "0755", - require => Package["munin-node"], + 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"], } } - } - - if ($config) { - file { "/etc/munin/plugin-conf.d/${config}": + } else { + file { "/etc/munin/plugin-conf.d/${name}": ensure => present, - source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}", - "puppet:///files/munin/plugin-conf/${config}", - "puppet:///modules/munin/plugin-conf/${config}", ], + mode => "0644", owner => "root", group => $::operatingsystem ? { "openbsd" => "wheel", default => "root", }, - mode => "0644", - notify => Service["munin-node"], - require => $::operatingsystem ? { - "openbsd" => File["/usr/local/libexec/munin/plugins/${name}"], - default => File["/usr/share/munin/plugins/${name}"], - }, + content => "[${name}]\ncommand /bin/true\n", + notify => Exec["munin-node-configure"], } } - case $::operatingsystem { - OpenBSD: { - 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}"], - } - } - default: { - 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}"], - } - } - } - -} - - -# Disable munin plugin. -# -define munin::disable() { - - file { "/etc/munin/plugin-conf.d/${name}": - ensure => present, - mode => "0644", - owner => "root", - group => $::operatingsystem ? { - "openbsd" => "wheel", - default => "root", - }, - content => "[${name}]\ncommand /bin/true\n", - notify => Exec["munin-node-configure"], - } - }