Revert "refactor static-components.conf.erb a bit - no logic changes yet"
[mirror/dsa-puppet.git] / modules / monit / manifests / init.pp
1 # = Class: monit
2 #
3 # This class installs and configures monit
4 #
5 # == Sample Usage:
6 #
7 #   include monit
8 #
9 class monit {
10         if $::lsbmajdistrelease <= 7 {
11                 package { 'monit':
12                         ensure => installed
13                 }
14
15                 augeas { 'inittab_monit':
16                         context => '/files/etc/inittab',
17                         changes => [
18                                 'set mo/runlevels 2345',
19                                 'set mo/action respawn',
20                                 "set mo/process \"/usr/bin/monit -d 300 -I -c /etc/monit/monitrc -s /var/lib/monit/monit.state\"",
21                         ],
22                         notify => Exec['init q'],
23                 }
24
25                 file { '/etc/monit/':
26                         ensure  => directory,
27                         mode    => '0755',
28                         purge   => true,
29                         notify  => Exec['service monit stop'],
30                         require => Package['monit'],
31                 }
32                 file { '/etc/monit/monit.d':
33                         ensure  => directory,
34                         mode    => '0750',
35                         purge   => true,
36                 }
37                 file { '/etc/monit/monitrc':
38                         content => template('monit/monitrc.erb'),
39                         mode    => '0400'
40                 }
41                 file { '/etc/monit/monit.d/01puppet':
42                         source  => 'puppet:///modules/monit/puppet',
43                         mode    => '0440'
44                 }
45                 file { '/etc/monit/monit.d/00debian.org':
46                         source  => 'puppet:///modules/monit/debianorg',
47                         mode    => '0440'
48                 }
49                 file { '/etc/default/monit':
50                         content => template('monit/default.erb'),
51                         require => Package['monit'],
52                         notify  => Exec['service monit stop']
53                 }
54
55                 exec { 'service monit stop':
56                         refreshonly => true,
57                 }
58         } else {
59                 package { 'monit':
60                         ensure => purged
61                 }
62                 file { [ '/etc/monit/',
63                          '/etc/monit/monit.d',
64                          '/etc/monit/monit.d/01puppet',
65                          '/etc/monit/monit.d/00debian.org'
66                         ]:
67                         ensure  => absent,
68                         force   => true
69                 }
70         }
71 }