Hi,
I’m trying to implement a notification handler.
My problem is were shall I put the class files?
Dennis
Hi,
I’m trying to implement a notification handler.
My problem is were shall I put the class files?
Dennis
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.
HTH,
Dan DeLeo
On Thu, Jul 1, 2010 at 8:28 AM, dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis
Yeah. I figured something like that.
Works fine. Thanks for your reply
Am 01.07.2010 um 17:42 schrieb Daniel DeLeo:
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.HTH,
Dan DeLeoOn Thu, Jul 1, 2010 at 8:28 AM, dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis
I've also thought it would be easy to distribute as a gem.
Adam
On Thu, Jul 1, 2010 at 9:25 AM, Dennis Kong dennis.kong@stylefruits.de wrote:
Yeah. I figured something like that.
Works fine. Thanks for your replyAm 01.07.2010 um 17:42 schrieb Daniel DeLeo:
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.HTH,
Dan DeLeoOn Thu, Jul 1, 2010 at 8:28 AM, dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis
--
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com
Is there some documentation for writing handlers?
I've been searching the wiki and I don't see any entries on handlers.
I never did anything in ruby before Chef, so if there's some ruby way of
figuring this out (like using the "ri" command or something), I'd
appreciate it.
-Paul
On 7/1/10 4:23 PM, Adam Jacob wrote:
I've also thought it would be easy to distribute as a gem.
Adam
On Thu, Jul 1, 2010 at 9:25 AM, Dennis Kongdennis.kong@stylefruits.de wrote:
Yeah. I figured something like that.
Works fine. Thanks for your replyAm 01.07.2010 um 17:42 schrieb Daniel DeLeo:
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.HTH,
Dan DeLeoOn Thu, Jul 1, 2010 at 8:28 AM,dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis
I've only seen this blog post:
On Aug 11, 2010, at 5:56 PM, Paul Choi wrote:
Is there some documentation for writing handlers?
I've been searching the wiki and I don't see any entries on handlers.I never did anything in ruby before Chef, so if there's some ruby way of figuring this out (like using the "ri" command or something), I'd appreciate it.
-Paul
On 7/1/10 4:23 PM, Adam Jacob wrote:
I've also thought it would be easy to distribute as a gem.
Adam
On Thu, Jul 1, 2010 at 9:25 AM, Dennis Kongdennis.kong@stylefruits.de wrote:
Yeah. I figured something like that.
Works fine. Thanks for your replyAm 01.07.2010 um 17:42 schrieb Daniel DeLeo:
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.HTH,
Dan DeLeoOn Thu, Jul 1, 2010 at 8:28 AM,dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis
On Wed, Aug 11, 2010 at 5:59 PM, Alex Soto apsoto@gmail.com wrote:
I've only seen this blog post:
Chef 0.9.0 and Ohai 0.5.6 Released - Chef Blog | ChefOn Aug 11, 2010, at 5:56 PM, Paul Choi wrote:
Is there some documentation for writing handlers?
I've been searching the wiki and I don't see any entries on handlers.I never did anything in ruby before Chef, so if there's some ruby way of figuring this out (like using the "ri" command or something), I'd appreciate it.
We haven't added documentation to the wiki yet, but there is inline
documentation in the source with another example:
http://github.com/opscode/chef/blob/master/chef/lib/chef/handler.rb
FYI, that 'def_delegator' stuff is just a fancy way to make a method like:
def start_time
@run_status.start_time
end
So you can use them like a regular method.
HTH,
Dan DeLeo
Regarding where to place custom notification handler
I think that keep it as special cookbook recipe is much better option
As we do´nt need to update individual client config when we change the notification handler or
upgrade chef-client
This is example of my chef_run_notify cookbook
#file cookbooks/chef_run_notify/recipes/default.rb
require 'net/smtp'
class CustomLogHandler < Chef::Handler
def report
Chef::Log.info("#{self.class.name} started for #{node.name}")
Chef::Log.info("#{self.class.name} Updated #{updated_resources.size} of #{all_resources.size} resources")
if updated_resources.size > 0 or failed?
message = "From: rob@mydomain.com\n"
message << "To: bob@mydomain.com\n"
if failed?
message << "Subject: Chef Run on #{node.name} in #{elapsed_time} seconds FAILED\n"
else
message << "Subject: Chef Run on #{node.name} in #{elapsed_time} seconds SUCCEED\n"
end
message << "Date: #{Time.now.rfc2822}\n\n"
if success?
message << "Updated\n #{updated_resources.map {|r| r.name}.join("\n ")}"
else
message << "#{run_status.formatted_exception}\n"
message << Array(backtrace).join("\n")
end
node[:mailhost] ||= Mash.new
node[:mailhost][:host] ||= 'mailhost.mydomain.com'
node[:mailhost][:port] ||= '25'
Chef::Log.info("#{self.class.name} notify by e-mail via #{node[:mailhost][:host]}:#{node[:mailhost][:port]}")
Net::SMTP.start(node[:mailhost][:host], node[:mailhost][:port].to_i) do |smtp|
smtp.send_message message, 'rob@mydomain.com', 'bob@mydomain.com'
end
end
Chef::Log.info("#{self.class.name} completed")
end
end
Chef::Config.report_handlers << CustomLogHandler.new # these fire at the end of a successful run
Chef::Config.exception_handlers << CustomLogHandler.new # these fire at the end of a failed run
-----Mensaje original-----
De: Alex Soto [mailto:apsoto@gmail.com]
Enviado el: jueves, 12 de agosto de 2010 3:00
Para: chef@lists.opscode.com
Asunto: [chef] Re: Re: Re: Re: Re: Notification Handler
I've only seen this blog post:
On Aug 11, 2010, at 5:56 PM, Paul Choi wrote:
Is there some documentation for writing handlers?
I've been searching the wiki and I don't see any entries on handlers.I never did anything in ruby before Chef, so if there's some ruby way of figuring this out (like using the "ri" command or something), I'd appreciate it.
-Paul
On 7/1/10 4:23 PM, Adam Jacob wrote:
I've also thought it would be easy to distribute as a gem.
Adam
On Thu, Jul 1, 2010 at 9:25 AM, Dennis Kongdennis.kong@stylefruits.de wrote:
Yeah. I figured something like that.
Works fine. Thanks for your replyAm 01.07.2010 um 17:42 schrieb Daniel DeLeo:
Ohai!
Right now we don't have a standard for this. I'd recommend putting
them in a directory under /etc/chef, e.g., /etc/chef/handlers. You
will have to require the files in your client.rb file to use them.HTH,
Dan DeLeoOn Thu, Jul 1, 2010 at 8:28 AM,dennis.kong@stylefruits.de wrote:
Hi,
I'm trying to implement a notification handler.
My problem is were shall I put the class files?Dennis