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