Skip to content

Commit

Permalink
Travis config: exlude LWRP suggestion from foodcritic, Bump version o…
Browse files Browse the repository at this point in the history
…f foodcritic to 4.0.0, Delete link to RDOC, Cleanup foodcritic warnings: normalize node attribute access to string vs symbol, update service notification, update conditional in recipes/default... Addresses Issue #58
  • Loading branch information
yourabi committed Sep 10, 2014
1 parent 94b6958 commit b5f1dea
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ gemfile:
- test/Gemfile
rvm:
- 1.9.3
script: bundle exec rake foodcritic
script: bundle exec rake foodcritic -f any -t ~FC015
31 changes: 17 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ GEM
fauxhai (2.0.0)
net-ssh
ohai
foodcritic (3.0.3)
foodcritic (4.0.0)
erubis
gherkin (~> 2.11.7)
nokogiri (~> 1.5.4)
gherkin (~> 2.11)
nokogiri (~> 1.5)
rake
treetop (~> 1.4.10)
yajl-ruby (~> 1.1.0)
gherkin (2.11.8)
rufus-lru (~> 1.0)
treetop (~> 1.4)
yajl-ruby (~> 1.1)
gherkin (2.12.2)
multi_json (~> 1.3)
hashie (2.0.5)
highline (1.6.20)
Expand All @@ -53,21 +54,23 @@ GEM
chef
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.6.0)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.3.0)
mixlib-config (2.0.0)
mixlib-log (1.6.0)
mixlib-shellout (1.3.0)
moneta (0.6.0)
multi_json (1.8.2)
multi_json (1.10.1)
net-ssh (2.7.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
nokogiri (1.5.10)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
ohai (6.20.0)
ipaddress
mixlib-cli
Expand All @@ -76,15 +79,15 @@ GEM
mixlib-shellout
systemu (~> 2.5.2)
yajl-ruby
polyglot (0.3.3)
polyglot (0.3.5)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puma (1.6.3)
rack (~> 1.2)
rack (1.5.2)
rake (10.1.0)
rake (10.3.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.14.1)
Expand All @@ -95,12 +98,12 @@ GEM
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rufus-lru (1.0.5)
slop (3.4.7)
systemu (2.5.2)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
yajl-ruby (1.1.0)
treetop (1.5.3)
polyglot (~> 0.3)
yajl-ruby (1.2.1)

PLATFORMS
ruby
Expand Down
1 change: 0 additions & 1 deletion README.rdoc

This file was deleted.

52 changes: 26 additions & 26 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
default[:monit][:notify_email] = "notify@example.com"
default[:monit][:alert_blacklist] = %w( action, instance, pid, ppid )
default["monit"]["notify_email"] = "notify@example.com"
default["monit"]["alert_blacklist"] = %w( action, instance, pid, ppid )

default[:monit][:logfile] = 'syslog facility log_daemon'
default["monit"]["logfile"] = 'syslog facility log_daemon'

default[:monit][:poll_period] = 60
default[:monit][:poll_start_delay] = 120
default["monit"]["poll_period"] = 60
default["monit"]["poll_start_delay"] = 120

default[:monit][:mail_format][:subject] = "$SERVICE $EVENT"
default[:monit][:mail_format][:from] = "monit@#{node['fqdn']}"
default[:monit][:mail_format][:message] = <<-EOS
default["monit"]["mail_format"]["subject"] = "$SERVICE $EVENT"
default["monit"]["mail_format"]["from"] = "monit@#{node['fqdn']}"
default["monit"]["mail_format"]["message"] = <<-EOS
Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
Yours sincerely,
monit
EOS

default[:monit][:mailserver][:host] = "localhost"
default[:monit][:mailserver][:port] = nil
default[:monit][:mailserver][:username] = nil
default[:monit][:mailserver][:password] = nil
default[:monit][:mailserver][:password_suffix] = nil
default[:monit][:mailserver][:encryption] = nil
default[:monit][:mailserver][:timeout] = 60
default["monit"]["mailserver"]["host"] = "localhost"
default["monit"]["mailserver"]["port"] = nil
default["monit"]["mailserver"]["username"] = nil
default["monit"]["mailserver"]["password"] = nil
default["monit"]["mailserver"]["password_suffix"] = nil
default["monit"]["mailserver"]["encryption"] = nil
default["monit"]["mailserver"]["timeout"] = 60

default[:monit][:port] = 3737
default[:monit][:address] = nil
default[:monit][:ssl] = false
default[:monit][:cert] = "/etc/monit/monit.pem"
default[:monit][:allow] = []
default[:monit][:username] = nil
default[:monit][:password] = nil
default[:monit][:ssh_port] = 22
default["monit"]["port"] = 3737
default["monit"]["address"] = nil
default["monit"]["ssl"] = false
default["monit"]["cert"] = "/etc/monit/monit.pem"
default["monit"]["allow"] = []
default["monit"]["username"] = nil
default["monit"]["password"] = nil
default["monit"]["ssh_port"] = 22

default[:monit][:eventqueue][:set] = true
default[:monit][:eventqueue][:basedir] = "/var/monit"
default[:monit][:eventqueue][:slots] = 1000
default["monit"]["eventqueue"]["set"] = true
default["monit"]["eventqueue"]["basedir"] = "/var/monit"
default["monit"]["eventqueue"]["slots"] = 1000
4 changes: 2 additions & 2 deletions attributes/unicorn.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
default[:monit][:unicorn][:pid_dir] = '/path/to/pids'
default[:monit][:unicorn][:worker_count] = 1
default["monit"]["unicorn"]["pid_dir"] = '/path/to/pids'
default["monit"]["unicorn"]["worker_count"] = 1
4 changes: 2 additions & 2 deletions definitions/monitrc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
source params[:template_source]
cookbook params[:template_cookbook]
variables params[:variables]
notifies :restart, resources(:service => "monit"), params[:reload]
notifies :restart, "service[monit]", params[:reload]
action :create
end
else
file "/etc/monit/conf.d/#{params[:name]}.conf" do
action :delete
notifies :restart, resources(:service => "monit"), params[:reload]
notifies :restart, "service[monit]", params[:reload]
end
end
end
15 changes: 7 additions & 8 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package "monit"

if platform?("ubuntu") || platform?("debian")
cookbook_file "/etc/default/monit" do
source "monit.default"
owner "root"
group "root"
mode 0644
end
cookbook_file "/etc/default/monit" do
source "monit.default"
owner "root"
group "root"
mode 0644
only_if { platform?("ubuntu") || platform?("debian") }
end


directory "/etc/monit/conf.d/" do
owner 'root'
group 'root'
Expand All @@ -27,6 +27,5 @@

service "monit" do
action [:enable, :start]
enabled true
supports [:start, :restart, :stop]
end
54 changes: 27 additions & 27 deletions templates/default/monitrc.erb
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
set daemon <%= @node[:monit][:poll_period] %>
<% if @node[:monit][:poll_start_delay] %>
with start delay <%= @node[:monit][:poll_start_delay] %>
set daemon <%= @node["monit"]["poll_period"] %>
<% if @node["monit"]["poll_start_delay"] %>
with start delay <%= @node["monit"]["poll_start_delay"] %>
<% end %>

set logfile <%= @node[:monit][:logfile] %>
set logfile <%= @node["monit"]["logfile"] %>

set mailserver <%= @node[:monit][:mailserver][:host] %><%= " port #{@node[:monit][:mailserver][:port]}" if @node[:monit][:mailserver][:port] %>
<% if @node[:monit][:mailserver][:username] %>
username "<%= @node[:monit][:mailserver][:username] %>"
set mailserver <%= @node["monit"]["mailserver"]["host"] %><%= " port #{@node["monit"]["mailserver"]["port"]}" if @node["monit"]["mailserver"]["port"] %>
<% if @node["monit"]["mailserver"]["username"] %>
username "<%= @node["monit"]["mailserver"]["username"] %>"
<% end %>
<% if @node[:monit][:mailserver][:password] %>
password "<%= @node[:monit][:mailserver][:password] %>"<%= " #{@node[:monit][:mailserver][:password_suffix]}" if @node[:monit][:mailserver][:password_suffix] %>
<% if @node["monit"]["mailserver"]["password"] %>
password "<%= @node["monit"]["mailserver"]["password"] %>"<%= " #{@node["monit"]["mailserver"]["password_suffix"]}" if @node["monit"]["mailserver"]["password_suffix"] %>
<% end %>
<% if @node[:monit][:mailserver][:encryption] %>
using <%= @node[:monit][:mailserver][:encryption] %>
<% if @node["monit"]["mailserver"]["encryption"] %>
using <%= @node["monit"]["mailserver"]["encryption"] %>
<% end %>
<% if @node[:monit][:mailserver][:timeout] %>
with timeout <%= @node[:monit][:mailserver][:timeout] %> seconds
<% if @node["monit"]["mailserver"]["timeout"] %>
with timeout <%= @node["monit"]["mailserver"]["timeout"] %> seconds
<% end %>
<% if @node[:monit][:eventqueue][:set] %>
<% if @node["monit"]["eventqueue"]["set"] %>
set eventqueue
basedir <%= @node[:monit][:eventqueue][:basedir] %> # set the base directory where events will be stored
<%= "slots #{@node[:monit][:eventqueue][:slots]}" if @node[:monit][:eventqueue][:slots] %>
basedir <%= @node["monit"]["eventqueue"]["basedir"] %> # set the base directory where events will be stored
<%= "slots #{@node["monit"]["eventqueue"]["slots"]}" if @node["monit"]["eventqueue"]["slots"] %>
<% end %>

set mail-format {
from: <%= @node[:monit][:mail_format][:from] %>
subject: <%= @node[:monit][:mail_format][:subject] %>
message: <%= @node[:monit][:mail_format][:message] %>
from: <%= @node["monit"]["mail_format"]["from] %>
subject: <%= @node["monit"]["mail_format"]["subject"] %>
message: <%= @node["monit"]["mail_format"]["message"] %>
}

set alert <%= @node[:monit][:notify_email] %><%= " NOT ON { #{@node[:monit][:alert_blacklist].join(", ")} }" unless @node[:monit][:alert_blacklist].empty? %>
set alert <%= @node["monit"]["notify_email"] %><%= " NOT ON { #{@node["monit"]["alert_blacklist"].join(", ")} }" unless @node["monit"]["alert_blacklist"].empty? %>

set httpd port <%= @node[:monit][:port] %>
<%= "use address #{@node[:monit][:address]}" if @node[:monit][:address] %>
<% @node[:monit][:allow].each do |a| %>
allow <%= "#{a}" %>
set httpd port <%= @node["monit"]["port"] %>
<%= "use address #{@node["monit"]["address"]}" if @node["monit"]["address"] %>
<% @node["monit"]["allow"].each do |a| %>
allow <%= "a" %>
<% end %>
<%= "allow #{@node[:monit][:username]}:#{@node[:monit][:password]}" if @node[:monit][:username] %>
<% if node[:monit][:ssl] %>
<%= "allow #{@node["monit"]["username"]}:#{@node["monit"]["password"]}" if @node["monit"]["username"] %>
<% if node["monit"]["ssl"] %>
ssl enable
pemfile <%= @node[:monit][:cert] %>
pemfile <%= @node["monit"]["cert"] %>
<% end %>

include /etc/monit/conf.d/*.conf
10 changes: 5 additions & 5 deletions templates/default/unicorn.conf.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
check process unicorn with pidfile <%= node[:monit][:unicorn][:pid_dir] %>/unicorn.pid
check process unicorn with pidfile <%= node["monit"]["unicorn"]["pid_dir"] %>/unicorn.pid
start program "/etc/init.d/unicorn start"
stop program "/etc/init.d/unicorn stop"
if 5 restarts within 5 cycles then timeout

<% node[:monit][:unicorn][:worker_count].times do |i| %>
check process unicorn_worker_<%= i %> with pidfile <%= File.join(node[:monit][:unicorn][:pid_dir], "unicorn.worker.#{i}.pid") %>
<% unless node[:monit][:notify_email].nil? || node[:monit][:notify_email] == '' %>
alert <%= node[:monit][:notify_email] %> only on { pid }
<% node["monit"]["unicorn"]["worker_count"].times do |i| %>
check process unicorn_worker_<%= i %> with pidfile <%= File.join(node["monit"]["unicorn"]["pid_dir"], "unicorn.worker.#{i}.pid") %>
<% unless node["monit"]["notify_email"].nil? || node["monit"]["notify_email"] == '' %>
alert <%= node["monit"]["notify_email"] %> only on { pid }
<% end %>
if changed pid 2 times within 60 cycles then alert
if memory usage > 16% for 1 cycles then
Expand Down

0 comments on commit b5f1dea

Please sign in to comment.