Skip to content
Browse files

Switch from "library" to "definition".

  • Loading branch information...
1 parent 059f5c3 commit 5e84711d5c48f9f1610c6dd6cb6367f6c6ee2719 @organicveggie organicveggie committed Mar 22, 2012
Showing with 22 additions and 24 deletions.
  1. +19 −0 definitions/monitrc.rb
  2. +0 −19 libraries/monitrc.rb
  3. +3 −5 recipes/default.rb
View
19 definitions/monitrc.rb
@@ -0,0 +1,19 @@
+# reload Reload monit so it notices the new service. :delayed (default) or :immediately.
+define :monitrc, :action => :enable, :reload => :delayed do
+ if params[:enable]
+ template "/etc/monit/conf.d/#{name}.conf" do
+ owner "root"
+ group "root"
+ mode 0644
+ source "#{name}.conf.erb"
+ variables params
+ notifies :restart, resources(:service => "monit"), params[:reload]
+ action :create
+ end
+ else
+ template "/etc/monit/conf.d/#{name}.conf" do
+ action :delete
+ notifies :restart, resources(:service => "monit"), params[:reload]
+ end
+ end
+end
View
19 libraries/monitrc.rb
@@ -1,19 +0,0 @@
-class Chef
- class Recipe
- # name The name of the service. Looks for a template named NAME.conf
- # variables Hash of variables to pass to the template
- # reload Reload monit so it notices the new service. :delayed (default) or :immediately.
- def monitrc(name, variables={}, reload = :delayed)
- log "Making monitrc for: #{name}"
- template "/etc/monit/conf.d/#{name}.conf" do
- owner "root"
- group "root"
- mode 0644
- source "#{name}.conf.erb"
- variables variables
- notifies :restart, resources(:service => "monit"), reload
- action :create
- end
- end
- end
-end
View
8 recipes/default.rb
@@ -1,6 +1,4 @@
-package "monit" do
- action :install
-end
+package "monit"
if platform?("ubuntu")
cookbook_file "/etc/default/monit" do
@@ -12,7 +10,7 @@
end
service "monit" do
- action :start
+ action [:enable, :start]
enabled true
supports [:start, :restart, :stop]
end
@@ -22,7 +20,7 @@
group "root"
mode 0700
source 'monitrc.erb'
- notifies :restart, resources(:service => "monit"), :immediate
+ notifies :restart, resources(:service => "monit"), :delayed
end
directory "/etc/monit/conf.d/" do

0 comments on commit 5e84711

Please sign in to comment.
Something went wrong with that request. Please try again.