Skip to content

Commit

Permalink
Add more flexibility to the monitrc definition by allowing monit conf…
Browse files Browse the repository at this point in the history
…igs to be impelemented in third-party cookbooks.
  • Loading branch information
freerobby committed Jul 4, 2012
1 parent 2cb7d91 commit ed83113
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions definitions/monitrc.rb
@@ -1,13 +1,17 @@
# reload: Reload monit so it notices the new service. :delayed (default) or :immediately.
# action: :enable To create the monitoring config (default), or :disable to remove it.
define :monitrc, :action => :enable, :reload => :delayed, :variables => {} do
# variables: Hash of instance variables to pass to the ERB template
# template_cookbook: the cookbook in which the configuration resides
# template_source: filename of the ERB configuration template, defaults to <LWRP Name>.conf.erb
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
owner "root"
group "root"
mode 0644
source "#{params[:name]}.conf.erb"
cookbook "monit"
source params[:template_source]
cookbook params[:template_cookbook]
variables params[:variables]
notifies :restart, resources(:service => "monit"), params[:reload]
action :create
Expand Down

0 comments on commit ed83113

Please sign in to comment.