Chef 13 chef_handler doesn't work


#1

Hi guys,
After upgrading to 13
chef_handler doesn’t work

chef undefined method `new’ for ChefHandler:Module

51: action :disable do
52: new_resource.supports.each_key do |type|
53: unregister_handler(type, new_resource.class_name)
54: end
55: end
56:
57: def load_current_resource
58>> @current_resource = Chef::Resource::ChefHandler.new(new_resource.name)
59: @current_resource.class_name(new_resource.class_name)
60: @current_resource.source(new_resource.source)
61: @current_resource
62: end
63:
64: private
65:
66: def collect_args(resource_args = [])
67: if resource_args.is_a? Array

I’m using chef_handler to send emails, here’s the code

class SendEmail < Chef::Handler
def initialize(mailhost=“malhost”, mail_port=“25”, def_emails={“from” => "test@sample.com", “to” => "test@sample.com"})
@def_emails=def_emails
@mailhost=mailhost
@mail_port=mail_port
end

def report
if run_status.failed? then
send_email(@def_emails, “Chef run failed on #{node.name}”, “#{run_status.formatted_exception}\n” + Array(backtrace).join("\n"), @mailhost, @mail_port )
else
send_email(@def_emails, “Chef run complete on #{node.name}”, “”, @mailhost, @mail_port )
end
end
def send_email (def_emails, subject, body, mailhost, mail_port)
message = "From: Chef #{node.environment} <#{def_emails[‘from’]}>\n"
message << "To: #{def_emails[‘to’]}\n"
message << "Subject: #{subject}\n"
message << "Date: #{Time.now.rfc2822}\n\n"
message << "#{body}\n"
Net::SMTP.start(‘mailhost’, mail_port) do |smtp|
smtp.send_message message, def_emails[‘from’], def_emails[‘to’]
end
end
end

Any thoughts?