munin installation (+ test auf immer1-0)
[puppet_munin.git] / manifests / client.pp
1 # client.pp - configure a munin node
2 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
3 # See LICENSE for the full license granted to you.
4
5 class munin::client {
6
7         $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } 
8         $munin_host_real = $munin_host ? {
9                 '' => '*',
10                 'fqdn' => '*',
11                 default => $munin_host
12         }
13
14         case $operatingsystem {
15                 darwin: { include munin::client::darwin }
16                 debian: {
17                         include munin::client::debian
18                         include munin::plugins::debian
19                 }
20                 ubuntu: {
21                         info ( "Trying to configure Ubuntu's munin with Debian class" )
22                         include munin::client::debian
23                         include munin::plugins::debian
24                 }
25                 default: { fail ("Don't know how to handle munin on $operatingsystem") }
26         }
27
28         case $kernel {
29                 linux: {
30                         case $vserver {
31                                 guest: { include munin::plugins::vserver }
32                                 default: {
33                                         include munin::plugins::linux
34                                         case $virtual {
35                                                 xen0: { include munin::plugins::xen }
36                                         }
37                                 }
38                         }
39                 }
40                 default: {
41                         err( "Don't know which munin plugins to install for $kernel" )
42                 }
43         }
44
45 }
46
47 define munin::register()
48 {
49         $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } 
50         $munin_host_real = $munin_host ? {
51                 '' => $fqdn,
52                 'fqdn' => $fqdn,
53                 default => $munin_host
54         }
55
56         @@file { "${NODESDIR}/${name}_${munin_port_real}":
57                 ensure => present,
58                 content => template("munin/defaultclient.erb"),
59         }
60 }
61
62 define munin::register_snmp()
63 {
64         @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
65                 ensure => present,
66                 content => template("munin/snmpclient.erb"),
67         }
68 }
69
70 class munin::client::darwin 
71 {
72         file { "/usr/share/snmp/snmpd.conf": 
73                 mode => 744,
74                 content => template("munin/darwin_snmpd.conf.erb"),
75                 group  => staff,
76                 owner  => root,
77         }
78         delete_matching_line{"startsnmpdno":
79                 file => "/etc/hostconfig",
80                 pattern => "SNMPSERVER=-NO-",
81         }
82         line { "startsnmpdyes":
83                 file => "/etc/hostconfig",
84                 line => "SNMPSERVER=-YES-",
85                 notify => Exec["/sbin/SystemStarter start SNMP"],
86         }
87         exec{"/sbin/SystemStarter start SNMP":
88                 noop => false,
89         } 
90         munin::register_snmp { $fqdn: }
91 }
92
93 class munin::client::debian 
94 {
95
96         package { "munin-node": ensure => installed }
97
98         file {
99                 "/etc/munin/":
100                         ensure => directory,
101                         mode => 0755, owner => root, group => root;
102                 "/etc/munin/munin-node.conf":
103                         content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
104                         mode => 0644, owner => root, group => root,
105                         # this has to be installed before the package, so the postinst can
106                         # boot the munin-node without failure!
107                         before => Package["munin-node"],
108                         notify => Service["munin-node"],
109         }
110
111         service { "munin-node":
112                 ensure => running, 
113                 # sarge's munin-node init script has no status
114                 hasstatus => $lsbdistcodename ? { sarge => false, default => true }
115         }
116
117         munin::register { $fqdn: }
118
119         # workaround bug in munin_node_configure
120         plugin { "postfix_mailvolume": ensure => absent }
121 }
122