lib/chef-irc-snitch.rb in chef-irc-snitch-0.0.2 vs lib/chef-irc-snitch.rb in chef-irc-snitch-0.0.3

- old
+ new

@@ -16,11 +16,11 @@ end def report Chef::Log.error("Chef run failed @ #{Time.now.getutc}, snitchin' to chefs via IRC") - gist = "#{run_status.formatted_exception}\n\n" + gist = "#{run_status.formatted_exception}\n" gist << Array(backtrace).join("\n") max_attempts = 2 gist_id = nil @@ -28,11 +28,12 @@ timeout(8) do res = Net::HTTP.post_form(URI.parse("http://gist.github.com/api/v1/json/new"), { "files[#{node.name}-#{Time.now.to_i.to_s}]" => gist, "login" => @github_user, "token" => @github_token, - "description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}" + "description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}", + "public" => false }) gist_id = JSON.parse(res.body)["gists"].first["repo"] end rescue Timeout::Error Chef::Log.error("Timed out while attempting to create a GitHub Gist, retrying ...") @@ -41,16 +42,17 @@ end Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}") max_attempts = 2 - message = "Chef run failed on #{node.name} => https://gist.github.com/#{gist_id}" + ip_address = (node.has_key? :ec2) ? node.ec2.public_ipv4 : node.ipaddress + message = "Chef run failed on #{node.name} (#{ip_address}) : https://gist.github.com/#{gist_id}" begin timeout(8) do ShoutBot.shout(@irc_uri, nil, @ssl) do |channel| channel.say message - Chef::Log.info("Informed chefs via IRC => '#{message}'") + Chef::Log.info("Informed chefs via IRC : #{message}") end end rescue Timeout::Error Chef::Log.error("Timed out while attempting to message Chefs via IRC, retrying ...") max_attempts -= 1