Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #63 issue. Added support for different platforms #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ GEM
puma (1.6.3)
rack (~> 1.2)
rack (1.5.2)
rake (10.3.2)
rake (10.4.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.99.0)
Expand Down
4 changes: 2 additions & 2 deletions definitions/monitrc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
define :monitrc, :action => :enable, :reload => :delayed, :variables => {}, :template_cookbook => "monit", :template_source => nil do
params[:template_source] ||= "#{params[:name]}.conf.erb"
if params[:action] == :enable
template "/etc/monit/conf.d/#{params[:name]}.conf" do
template File.join(node['monit']['conf_dir'], "#{params[:name]}.conf") do
owner "root"
group "root"
mode 0644
Expand All @@ -17,7 +17,7 @@
action :create
end
else
file "/etc/monit/conf.d/#{params[:name]}.conf" do
file File.join(node['monit']['conf_dir'], "#{params[:name]}.conf") do
action :delete
notifies :restart, "service[monit]", params[:reload]
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license "MIT"
description "Configures monit. Originally based off the 37 Signals Cookbook."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.7.5"
version "0.7.6"


attribute 'monit/notify_email',
Expand Down
13 changes: 11 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@
only_if { platform?("ubuntu") || platform?("debian") }
end

case node['platform']
when 'ubuntu', 'debian'
node.default['monit']['conf_file'] = '/etc/monit/monitrc'
node.default['monit']['conf_dir'] = '/etc/monit/conf.d/'

directory "/etc/monit/conf.d/" do
when 'redhat', 'fedora', 'centos' # ~FC024
node.default['monit']['conf_file'] = '/etc/monit.conf'
node.default['monit']['conf_dir'] = '/etc/monit.d/'
end

directory node['monit']['conf_dir'] do
owner 'root'
group 'root'
mode 0755
action :create
recursive true
end

template "/etc/monit/monitrc" do
template node['monit']['conf_file'] do
owner "root"
group "root"
mode 0700
Expand Down
6 changes: 4 additions & 2 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

describe 'monit::default' do
context "with default attributes" do
let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
let(:chef_run) do
runner = ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04').converge(described_recipe)
end

it 'creates /etc/monit/conf.d/' do
expect(chef_run).to create_directory('/etc/monit/conf.d/').with(user: 'root', group: 'root', mode: 0755)
Expand Down Expand Up @@ -36,7 +38,7 @@

context "with configuration" do
let(:chef_run) do
runner = ChefSpec::Runner.new do |node|
runner = ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04') do |node|
node.set[:monit][:notify_email] = '[email protected]'
node.set[:monit][:logfile] = '/var/log/monit.log'
node.set[:monit][:poll_period] = 30
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/postfix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'monit::postfix' do
let(:chef_run) do
runner = ChefSpec::Runner.new.converge(described_recipe)
runner = ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04').converge(described_recipe)
end

# Temporary soultion for testing definitions/monitrc.erb without monky patch.
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/postgres_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'monit::postgresql' do
let(:chef_run) { ChefSpec::Runner.new.converge described_recipe }
let(:chef_run) { ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04').converge described_recipe }

it 'creates /etc/monit/conf.d/postgresql.conf' do
expect(chef_run).to create_template('/etc/monit/conf.d/postgresql.conf').with(user: 'root', group: 'root', mode: 0644)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/resque_scheduler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'monit::resque_scheduler' do
let(:chef_run) do
ChefSpec::Runner.new do |node|
ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04') do |node|
node.set[:monit][:resque][:app_root] = '/www/myapp-test/current'
end.converge(described_recipe)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/resque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe 'monit::resque' do
def chef_run(monit_resque_attrs = {})
@chef_run ||= ChefSpec::Runner.new do |node|
@chef_run ||= ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04') do |node|
node.set[:monit][:resque] = monit_resque_attrs
end.converge described_recipe
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/unicorn_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'monit::unicorn' do
let(:chef_run) { ChefSpec::Runner.new.converge described_recipe }
let(:chef_run) { ChefSpec::Runner.new(:platform => 'ubuntu', :version => '12.04').converge described_recipe }

it 'creates /etc/monit/conf.d/unicorn.conf' do
expect(chef_run).to create_template('/etc/monit/conf.d/unicorn.conf').with(user: 'root', group: 'root', mode: 0644)
Expand Down