From 14c511f7f6791f56952bc312e5ff8cf4826bb14e Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 1 Oct 2008 19:54:20 +0000 Subject: tried to make munin-node installable and runable on openbsd --- files/openbsd/package/munin_openbsd.tar.gz | Bin 0 -> 97459 bytes manifests/client.pp | 79 ++++++++++++++++++++++------- manifests/plugin.pp | 57 ++++++++++++++------- 3 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 files/openbsd/package/munin_openbsd.tar.gz diff --git a/files/openbsd/package/munin_openbsd.tar.gz b/files/openbsd/package/munin_openbsd.tar.gz new file mode 100644 index 0000000..76ae644 Binary files /dev/null and b/files/openbsd/package/munin_openbsd.tar.gz differ diff --git a/manifests/client.pp b/manifests/client.pp index 9a7b772..b9e0c0a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -13,9 +13,9 @@ class munin::client { } case $operatingsystem { + openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } - debian: { include munin::client::debian } - ubuntu: { include munin::client::ubuntu } + debian,ubuntu: { include munin::client::debian } centos: { include munin::client::centos } gentoo: { include munin::client::gentoo } default: { include munin::client::base } @@ -48,15 +48,13 @@ define munin::register_snmp() } class munin::client::base { - package { "munin-node": ensure => installed } - service { "munin-node": + service { 'munin-node': ensure => running, enable => true, hasstatus => true, hasrestart => true, - require => Package[munin-node], } - file {"/etc/munin/": + file {'/etc/munin/': ensure => directory, mode => 0755, owner => root, group => 0; } @@ -64,18 +62,53 @@ class munin::client::base { '' => '127.0.0.1', default => $munin_allow } - file {"/etc/munin/munin-node.conf": - content => template("munin/munin-node.conf.$operatingsystem"), - # this has to be installed before the package, so the postinst can - # boot the munin-node without failure! - before => Package["munin-node"], - notify => Service['munin-node'], - mode => 0644, owner => root, group => 0, + file {'/etc/munin/munin-node.conf': + content => template("munin/munin-node.conf.$operatingsystem"), + notify => Service['munin-node'], + mode => 0644, owner => root, group => 0, } munin::register { $fqdn: } include munin::plugins::base } +# currently we install munin on openbsd by hand +# :( +class munin::openbsd inherits openbsd::base { + file{'/usr/src/munin_openbsd.tar.gz': + source => "puppet://$server/munin/openbsd/package/munin_openbsd.tar.gz", + owner => root, group => 0, mode => 0600; + } + package{ [ 'p5-Compress-Zlib', 'p5-Crypt-SSLeay', 'p5-HTML-Parser', + 'p5-HTML-Tagset', 'p5-HTTP-GHTTP', 'p5-LWP-UserAgent-Determined', + 'p5-Net-SSLeay', 'p5-Net-Server', 'p5-URI', 'p5-libwww', 'pcre', 'curl' ]: + ensure => installed, + before => File['/var/run/munin'], + } + exec{'extract_openbsd': + command => 'tar xzf /usr/src/munin_openbsd.tar.gz', + unless => 'test -d /opt/munin', + require => File['/usr/src/munin_openbsd.tar.gz'], + } + file{'/var/run/munin': + ensure => directory, + require => File['/usr/src/munin_openbsd.tar.gz'], + owner => root, group => 0, mode => 0755; + } + exec{'enable_munin_on_boot': + command => 'echo "if [ -x /opt/munin/sbin/munin-node ]; then echo -n \' munin\'; /opt/munin/sbin/munin-node; fi" >> /etc/rc.local', + unless => 'grep -q "if [ -x /opt/munin/sbin/munin-node ]; then echo -n \' munin\'; /opt/munin/sbin/munin-node; fi" >> /etc/rc.local', + require => File['/var/run/munin'], + } + Service['munin-node']{ + restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`', + stopt => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`', + start => '/opt/munin/sbin/munin-node', + hasstatus => false, + hasrestart => false, + require => File['/var/run/munin'], + } +} + class munin::client::darwin { file { "/usr/share/snmp/snmpd.conf": mode => 744, @@ -98,7 +131,19 @@ class munin::client::darwin { munin::register_snmp { $fqdn: } } -class munin::client::debian inherits munin::client::base { +class munin::client::package inherits munin::client::base { + package { 'munin-node': ensure => installed } + Service['munin-node']{ + require => Package[munin-node], + } + File['/etc/munin/munin-node.conf']{ + # this has to be installed before the package, so the postinst can + # boot the munin-node without failure! + before => Package['munin-node'], + } +} + +class munin::client::debian inherits munin::client::package { # the plugin will need that package { "iproute": ensure => installed } @@ -114,9 +159,7 @@ class munin::client::debian inherits munin::client::base { include munin::plugins::debian } -class munin::client::ubuntu inherits munin::client::debian {} - -class munin::client::gentoo inherits munin::client::base { +class munin::client::gentoo inherits munin::client::package { Package['munin-node'] { name => 'munin', category => 'net-analyzer', @@ -126,6 +169,6 @@ class munin::client::gentoo inherits munin::client::base { include munin::plugins::gentoo } -class munin::client::centos inherits munin::client::base { +class munin::client::centos inherits munin::client::package { include munin::plugins::centos } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 741de30..4395cef 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -8,18 +8,11 @@ class munin::plugin::scriptpaths { case $operatingsystem { - gentoo: { - $script_path = "/usr/libexec/munin/plugins" - } - debian: { - $script_path = "/usr/share/munin/plugins" - } - centos: { - $script_path = "/usr/share/munin/plugins" - } - default: { - $script_path = "/usr/share/munin/plugins" - } + gentoo: { $script_path = "/usr/libexec/munin/plugins" } + debian: { $script_path = "/usr/share/munin/plugins" } + centos: { $script_path = "/usr/share/munin/plugins" } + openbsd: { $script_path = "/opt/munin/lib/plugins/" } + default: { $script_path = "/usr/share/munin/plugins" } } } @@ -45,10 +38,14 @@ define munin::plugin ( } default: { debug ( "munin_plugin: making $plugin using src: $plugin_src" ) + case $kernel { + openbsd: { $basic_require = File['/var/run/munin'] } + default: { $basic_require = Package['munin-node'] } + } if $require { - $real_require = [ $require, Package['munin-node'] ] + $real_require = [ $require, $basic_require ] } else { - $real_require = Package['munin-node'] + $real_require = $basic_require } file { $plugin: ensure => "${real_script_path}/${plugin_src}", @@ -118,13 +115,24 @@ define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') { file { "munin_plugin_${name}": path => "$munin::plugin::scriptpaths::script_path/${name}", source => "puppet://$server/$real_source", - require => Package['munin-node'], mode => 0755, owner => root, group => 0; } + + case $kernel { + openbsd: { $basic_require = File['/var/run/munin'] } + default: { $basic_require = Package['munin-node'] } + } if $require { File["munin_plugin_${name}"]{ - require +> $require, + require => [ $basic_require, $require ], + } + } else { + File["munin_plugin_${name}"]{ + require => $basic_require, } + } + # register the plugin + if $require { munin::plugin{$name: ensure => $ensure, config => $config, require => $require } } else { munin::plugin{$name: ensure => $ensure, config => $config } @@ -135,19 +143,30 @@ define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') { class munin::plugins::base { file { - [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]: + [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: source => "puppet://$server/common/empty", ignore => '\.ignore', ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, mode => 0755, owner => root, group => 0, notify => Service['munin-node']; - "/etc/munin/plugin-conf.d/munin-node": + '/etc/munin/plugin-conf.d/munin-node': ensure => present, mode => 0644, owner => root, group => 0, notify => Service['munin-node'], - before => Package['munin-node']; } + case $kernel { + openbsd: { + File['/etc/munin/plugin-conf.d/munin-node']{ + before => File['/var/run/munin'], + } + } + default: { + File['/etc/munin/plugin-conf.d/munin-node']{ + before => Package['munin-node'], + } + } + } case $kernel { linux: { case $vserver { -- cgit v1.2.3