chef_gem "chef-handler-mail"
gem "chef-handler-mail"
chef_handler "MailHandler" do
source 'chef/handler/mail'
arguments :to_address => "root"
action :nothing
end.run_action(:enable)
Ohai chefs!
e.g.
Following is the snippet from the 'chef-client::config' recipe.
template "#{node["chef_client"]["conf_dir"]}/client.rb" do
source "client.rb.erb"
owner "root"
group root_group
mode 0644
variables :chef_node_name => chef_node_name
notifies :create, "ruby_block[reload_client_config]"
end
Its values can be overridden to customize it.
But what if I to edit the template itself or how to put the modified template in my cookbook to get rendered instead of editing the default template provided by the cookbook itself?
e.g.
Now I want to use `https://github.com/kisoku/chef-handler-mail`.
For this to work beside downloading, uploading to chef-server and using in roles/other-recipes, I've to add
#Using /etc/chef/config.rb
require 'rubygems'
require 'chef/handler/mail'
mail_handler = MailHandler.new
report_handlers << mail_handler
exception_handlers << mail_handler
to the template itself.
Now how to just override the default template provided by chef-client at `templates/default/client.rb.erb` only with the additional chef-handler-mail code appended to it?
@millisami
~Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Archive powered by MHonArc 2.6.16.