strange...
[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                 gentoo: {
26                         include munin::client::gentoo
27                         include munin::plugins::gentoo
28         
29                 }
30                 default: { fail ("Don't know how to handle munin on $operatingsystem") }
31         }
32
33         case $kernel {
34                 linux: {
35                         case $vserver {
36                                 guest: { include munin::plugins::vserver }
37                                 default: {
38                                         include munin::plugins::linux
39                                         case $virtual {
40                                                 xen0: { include munin::plugins::xen }
41                                         }
42                                 }
43                         }
44                 }
45                 default: {
46                         err( "Don't know which munin plugins to install for $kernel" )
47                 }
48         }
49
50 }
51
52 define munin::register()
53 {
54         $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } 
55         $munin_host_real = $munin_host ? {
56                 '' => $fqdn,
57                 'fqdn' => $fqdn,
58                 default => $munin_host
59         }
60
61         @@file { "${NODESDIR}/${name}_${munin_port_real}":
62                 ensure => present,
63                 content => template("munin/defaultclient.erb"),
64         }
65 }
66
67 define munin::register_snmp()
68 {
69         @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
70                 ensure => present,
71                 content => template("munin/snmpclient.erb"),
72         }
73 }
74
75 class munin::client::darwin 
76 {
77         file { "/usr/share/snmp/snmpd.conf": 
78                 mode => 744,
79                 content => template("munin/darwin_snmpd.conf.erb"),
80                 group  => staff,
81                 owner  => root,
82         }
83         delete_matching_line{"startsnmpdno":
84                 file => "/etc/hostconfig",
85                 pattern => "SNMPSERVER=-NO-",
86         }
87         line { "startsnmpdyes":
88                 file => "/etc/hostconfig",
89                 line => "SNMPSERVER=-YES-",
90                 notify => Exec["/sbin/SystemStarter start SNMP"],
91         }
92         exec{"/sbin/SystemStarter start SNMP":
93                 noop => false,
94         } 
95         munin::register_snmp { $fqdn: }
96 }
97
98 class munin::client::debian 
99 {
100
101         package { "munin-node": ensure => installed }
102
103         file {
104                 "/etc/munin/":
105                         ensure => directory,
106                         mode => 0755, owner => root, group => root;
107                 "/etc/munin/munin-node.conf":
108                         content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
109                         mode => 0644, owner => root, group => root,
110                         # this has to be installed before the package, so the postinst can
111                         # boot the munin-node without failure!
112                         before => Package["munin-node"],
113                         notify => Service["munin-node"],
114         }
115
116         service { "munin-node":
117                 ensure => running, 
118                 # sarge's munin-node init script has no status
119                 hasstatus => $lsbdistcodename ? { sarge => false, default => true }
120         }
121
122         munin::register { $fqdn: }
123
124         # workaround bug in munin_node_configure
125         plugin { "postfix_mailvolume": ensure => absent }
126 }
127
128 class munin::client::gentoo 
129 {
130         package { 'munin':
131                 ensure => present,
132                 category => $operatingsystem ? {
133                         gentoo => 'net-analyzer',
134                         default => '',
135                 },
136         }
137
138
139         file {
140                 "/etc/munin/":
141                         ensure => directory,
142                         mode => 0755, owner => root, group => root;
143                 "/etc/munin/munin-node.conf":
144                         content => template("munin/munin-node.conf.Gentoo."),
145                         mode => 0644, owner => root, group => root,
146                         # this has to be installed before the package, so the postinst can
147                         # boot the munin-node without failure!
148                         #before => Package["munin"],
149                         #notify => Service["munin"],
150         }
151
152         service { "munin":
153                 ensure => running, 
154         }
155
156         munin::register { $fqdn: }
157
158 }
159