Permalink
Browse files

update to more modern conventions

  • Loading branch information...
1 parent 2802d12 commit 27876c8b5945534ac2a1f4c25cc80a433ecd23ce @phlipper committed Dec 27, 2012
Showing with 33 additions and 26 deletions.
  1. +18 −18 attributes/default.rb
  2. +15 −8 recipes/default.rb
View
@@ -2,33 +2,33 @@
# Cookbook Name:: monit
# Attributes:: default
#
-# Copyright 2011, Phil Cohen
+# Author:: Phil Cohen <github@phlippers.net>
#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Copyright 2011-2012, Phil Cohen
#
-default["monit"]["polling_frequency"] = "20"
-default["monit"]["use_syslog"] = "true"
+
+# How frequently the monit daemon polls for changes.
+default["monit"]["polling_frequency"] = 20
+
+# Use syslog for logging instead of a logfile.
+default["monit"]["use_syslog"] = true
+
+# If not using syslog, the log file that monit will use.
default["monit"]["logfile"] = "/var/log/monit.log"
+
+# Email address that will be notified of events.
default["monit"]["alert_email"] = "root@localhost"
+# Enable the web interface and define credentials.
default["monit"]["web_interface"] = {
:enable => true,
:port => 2812,
:address => "localhost",
:allow => ["localhost", "admin:b1gbr0th3r"]
}
+# Email settings that will be used for notification of events.
default["monit"]["mail"] = {
:hostname => "localhost",
:port => 25,
@@ -41,11 +41,11 @@
:timeout => 30
}
-case platform
-when "redhat","centos","fedora"
+case node["platform"]
+when platform_family?("rhel"), platform_family?("fedora"), platform_family?("suse")
default["monit"]["main_config_path"] = "/etc/monit.conf"
- default["monit"]["includes_dir"] = "/etc/monit.d"
+ default["monit"]["includes_dir"] = "/etc/monit.d"
else
default["monit"]["main_config_path"] = "/etc/monit/monitrc"
- default["monit"]["includes_dir"] = "/etc/monit/conf.d"
+ default["monit"]["includes_dir"] = "/etc/monit/conf.d"
end
View
@@ -1,8 +1,13 @@
+#
+# Cookbook Name:: monit
+# Recipe:: default
+#
+
package "monit" do
action :install
end
-template "#{node["monit"]["main_config_path"]}" do
+template node["monit"]["main_config_path"] do
owner "root"
group "root"
mode "0700"
@@ -17,14 +22,16 @@
service "monit" do
service_name "monit"
- case node['platform']
- when "redhat","centos","scientific","fedora","suse","amazon"
+
+ case node["platform"]
+ when platform_family?("rhel"), platform_family?("fedora"), platform_family?("suse")
start_command "/sbin/service monit start"
restart_command "/sbin/service monit restart"
- when "debian","ubuntu"
+ when platform_family?("debian")
start_command "/usr/sbin/invoke-rc.d monit start"
restart_command "/usr/sbin/invoke-rc.d monit restart"
end
+
supports value_for_platform(
"debian" => { "4.0" => [ :restart, :start ], "default" => [ :restart, :start ] },
"ubuntu" => { "default" => [ :restart, :start ] },
@@ -36,17 +43,17 @@
action :enable
end
-case node['platform']
-when "debian", "ubuntu"
+if platform_family?("debian")
# enable startup
execute "enable-monit-startup" do
command "/bin/sed s/startup=0/startup=1/ -i /etc/default/monit"
not_if "grep 'startup=1' /etc/default/monit"
end
-else
end
# build monitrc files
%w[load ssh].each do |conf|
- monitrc conf, :category => "system"
+ monit_monitrc conf do
+ variables({ category: "system" })
+ end
end

0 comments on commit 27876c8

Please sign in to comment.