diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..d78b222 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,2 @@ +import "*" + diff --git a/manifests/monit.pp b/manifests/monit.pp new file mode 100644 index 0000000..52afa2a --- /dev/null +++ b/manifests/monit.pp @@ -0,0 +1,71 @@ +class monit { + package { 'monit': + ensure => installed, + } + + service { 'monit': + ensure => running, + enable => true, + hasrestart => true, + } + + file { '/etc/monit/monitrc': + mode => 600, + owner => root, + group => root, + content => template("/etc/puppet/modules/monit/templates/monitrc.erb"), + notify => Service['monit'], + require => File['/etc/monit'], + } + + file { '/etc/monit/': + mode => 755, + owner => root, + group => root, + ensure => directory, + notify => Service['monit'], + } + file { '/etc/monit/conf.d': + mode => 755, + owner => root, + group => root, + ensure => directory, + require => File['/etc/monit'], + notify => Service['monit'], + recurse => true, + purge => true, + } +} + +define monit::options ($interval, $mailserver, $email, $http_address, $http_allow, $http_user, $http_password) { + file { "/etc/monit/conf.d/options_$name": + mode => 600, + owner => root, + group => root, + content => template("/etc/puppet/modules/monit/templates/options.erb"), + notify => Service['monit'], + require => File['/etc/monit/conf.d'], + } +} + +define monit::pidcheck ($process_name, $pidfile, $start_prog, $stop_prog) { + file { "/etc/monit/conf.d/$name": + mode => 600, + owner => root, + group => root, + content => template("/etc/puppet/modules/monit/templates/pidcheck.erb"), + notify => Service['monit'], + require => File['/etc/monit/conf.d'], + } +} + +define monit::bindcheck ($bind_ips) { + file { "/etc/monit/conf.d/$name": + mode => 600, + owner => root, + group => root, + content => template("/etc/puppet/modules/monit/templates/bind.erb"), + notify => Service['monit'], + require => File['/etc/monit/conf.d'], + } +} diff --git a/templates/bind.erb b/templates/bind.erb new file mode 100644 index 0000000..c4c2c8c --- /dev/null +++ b/templates/bind.erb @@ -0,0 +1,12 @@ +# +# automatically generated by puppet for <%= fqdn %>, DO NOT MODIFY! +# +check process named with pidfile /var/run/named/named.pid + start program = "/etc/init.d/bind9 start" + stop program = "/etc/init.d/bind9 stop" + if failed host 127.0.0.1 port 53 type tcp protocol dns then restart + if failed host 127.0.0.1 port 53 type udp protocol dns then restart + <% bind_ips.each do |bind_ip| -%> + if failed host <%= bind_ip %> port 53 type tcp protocol dns then restart + if failed host <%= bind_ip %> port 53 type udp protocol dns then restart + <%- end %> diff --git a/templates/monitrc.erb b/templates/monitrc.erb new file mode 100644 index 0000000..331896d --- /dev/null +++ b/templates/monitrc.erb @@ -0,0 +1,17 @@ +# +# Monit control file +# +# Generated by puppet for <%= fqdn %>, DO NOT MODIFY! +# + +# log to syslog +set logfile syslog facility log_daemon + +# always monitor ssh +check process sshd with pidfile /var/run/sshd.pid + start program = "/etc/init.d/ssh start" + stop program = "/etc/init.d/ssh stop" + if failed port 22 protocol ssh then restart + +# include additional config files +include /etc/monit/conf.d/* diff --git a/templates/options.erb b/templates/options.erb new file mode 100644 index 0000000..8fe578e --- /dev/null +++ b/templates/options.erb @@ -0,0 +1,26 @@ +# +# automatically generated by puppet for <%= fqdn %>, DO NOT MODIFY! +# + +# check services interval +<% if has_variable?("interval") then %> +set daemon <%= interval %> +<% else %> +set daemon 180 +<% end %> + +<% if has_variable?("mailserver") then %> +set mailserver <%= mailserver %> +<% end %> + +<% if has_variable?("email") then %> +set alert <%= email %> +<% end %> + +<% if has_variable?("http_address") and has_variable?("http_allow") and has_variable?("http_user") and has_variable?("http_password") then %> +set httpd port 2812 and + use address <%= http_address %> + allow <%= http_allow %> + allow <%= http_user %>:<%= http_password %> +<% end %> + diff --git a/templates/pidcheck.erb b/templates/pidcheck.erb new file mode 100644 index 0000000..0cb5638 --- /dev/null +++ b/templates/pidcheck.erb @@ -0,0 +1,6 @@ +# +# automatically generated by puppet for <%= fqdn %>, DO NOT MODIFY! +# +check process <%= process_name %> with pidfile <%= pidfile %> + start program = "<%= start_prog %>" + stop program = "<%= stop_prog %>"