Remove monit on jessie
authorPeter Palfrader <peter@palfrader.org>
Sun, 30 Nov 2014 10:05:59 +0000 (10:05 +0000)
committerPeter Palfrader <peter@palfrader.org>
Sun, 30 Nov 2014 10:05:59 +0000 (10:05 +0000)
modules/monit/manifests/init.pp

index 2e0e68a..410ed82 100644 (file)
@@ -7,57 +7,70 @@
 #   include monit
 #
 class monit {
+       if $::lsbmajdistrelease <= 7 {
+               package { 'monit':
+                       ensure => installed
+               }
 
-       package { 'monit':
-               ensure => installed
-       }
+               $cmd = $::lsbdistcodename ? {
+                       'squeeze'    => '/usr/sbin/monit',
+                       default  => '/usr/bin/monit',
+               }
 
-       $cmd = $::lsbdistcodename ? {
-               'squeeze'    => '/usr/sbin/monit',
-               default  => '/usr/bin/monit',
-       }
+               augeas { 'inittab_monit':
+                       context => '/files/etc/inittab',
+                       changes => [
+                               'set mo/runlevels 2345',
+                               'set mo/action respawn',
+                               "set mo/process \"$cmd -d 300 -I -c /etc/monit/monitrc -s /var/lib/monit/monit.state\"",
+                       ],
+                       notify => Exec['init q'],
+               }
 
-       augeas { 'inittab_monit':
-               context => '/files/etc/inittab',
-               changes => [
-                       'set mo/runlevels 2345',
-                       'set mo/action respawn',
-                       "set mo/process \"$cmd -d 300 -I -c /etc/monit/monitrc -s /var/lib/monit/monit.state\"",
-               ],
-               notify => Exec['init q'],
-       }
-
-       file { '/etc/monit/':
-               ensure  => directory,
-               mode    => '0755',
-               purge   => true,
-               notify  => Exec['service monit stop'],
-               require => Package['monit'],
-       }
-       file { '/etc/monit/monit.d':
-               ensure  => directory,
-               mode    => '0750',
-               purge   => true,
-       }
-       file { '/etc/monit/monitrc':
-               content => template('monit/monitrc.erb'),
-               mode    => '0400'
-       }
-       file { '/etc/monit/monit.d/01puppet':
-               source  => 'puppet:///modules/monit/puppet',
-               mode    => '0440'
-       }
-       file { '/etc/monit/monit.d/00debian.org':
-               source  => 'puppet:///modules/monit/debianorg',
-               mode    => '0440'
-       }
-       file { '/etc/default/monit':
-               content => template('monit/default.erb'),
-               require => Package['monit'],
-               notify  => Exec['service monit stop']
-       }
+               file { '/etc/monit/':
+                       ensure  => directory,
+                       mode    => '0755',
+                       purge   => true,
+                       notify  => Exec['service monit stop'],
+                       require => Package['monit'],
+               }
+               file { '/etc/monit/monit.d':
+                       ensure  => directory,
+                       mode    => '0750',
+                       purge   => true,
+               }
+               file { '/etc/monit/monitrc':
+                       content => template('monit/monitrc.erb'),
+                       mode    => '0400'
+               }
+               file { '/etc/monit/monit.d/01puppet':
+                       source  => 'puppet:///modules/monit/puppet',
+                       mode    => '0440'
+               }
+               file { '/etc/monit/monit.d/00debian.org':
+                       source  => 'puppet:///modules/monit/debianorg',
+                       mode    => '0440'
+               }
+               file { '/etc/default/monit':
+                       content => template('monit/default.erb'),
+                       require => Package['monit'],
+                       notify  => Exec['service monit stop']
+               }
 
-       exec { 'service monit stop':
-               refreshonly => true,
+               exec { 'service monit stop':
+                       refreshonly => true,
+               }
+       } else {
+               package { 'monit':
+                       ensure => purged
+               }
+               file { [ '/etc/monit/',
+                        '/etc/monit/monit.d',
+                        '/etc/monit/monit.d/01puppet',
+                        '/etc/monit/monit.d/00debian.org'
+                       ]:
+                       ensure  => absent,
+                       force   => true
+               }
        }
 }