chef-irc-snitch 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef-irc-snitch/version.rb +1 -1
- data/lib/chef-irc-snitch.rb +6 -4
- metadata +1 -1
data/lib/chef-irc-snitch.rb
CHANGED
@@ -18,7 +18,7 @@ class IRCSnitch < Chef::Handler
|
|
18
18
|
def report
|
19
19
|
Chef::Log.error("Chef run failed @ #{Time.now.getutc}, snitchin' to chefs via IRC")
|
20
20
|
|
21
|
-
gist = "#{run_status.formatted_exception}\n
|
21
|
+
gist = "#{run_status.formatted_exception}\n"
|
22
22
|
gist << Array(backtrace).join("\n")
|
23
23
|
|
24
24
|
max_attempts = 2
|
@@ -30,7 +30,8 @@ class IRCSnitch < Chef::Handler
|
|
30
30
|
"files[#{node.name}-#{Time.now.to_i.to_s}]" => gist,
|
31
31
|
"login" => @github_user,
|
32
32
|
"token" => @github_token,
|
33
|
-
"description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}"
|
33
|
+
"description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}",
|
34
|
+
"public" => false
|
34
35
|
})
|
35
36
|
gist_id = JSON.parse(res.body)["gists"].first["repo"]
|
36
37
|
end
|
@@ -43,13 +44,14 @@ class IRCSnitch < Chef::Handler
|
|
43
44
|
Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}")
|
44
45
|
|
45
46
|
max_attempts = 2
|
46
|
-
|
47
|
+
ip_address = (node.has_key? :ec2) ? node.ec2.public_ipv4 : node.ipaddress
|
48
|
+
message = "Chef run failed on #{node.name} (#{ip_address}) : https://gist.github.com/#{gist_id}"
|
47
49
|
|
48
50
|
begin
|
49
51
|
timeout(8) do
|
50
52
|
ShoutBot.shout(@irc_uri, nil, @ssl) do |channel|
|
51
53
|
channel.say message
|
52
|
-
Chef::Log.info("Informed chefs via IRC
|
54
|
+
Chef::Log.info("Informed chefs via IRC : #{message}")
|
53
55
|
end
|
54
56
|
end
|
55
57
|
rescue Timeout::Error
|