chef-irc-snitch 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/chef-irc-snitch.gemspec +1 -1
- data/lib/chef-irc-snitch.rb +35 -35
- metadata +3 -5
data/chef-irc-snitch.gemspec
CHANGED
data/lib/chef-irc-snitch.rb
CHANGED
@@ -13,48 +13,48 @@ class IRCSnitch < Chef::Handler
|
|
13
13
|
@github_user = github_user
|
14
14
|
@github_token = github_token
|
15
15
|
@ssl = ssl
|
16
|
+
@timestamp = Time.now.getutc
|
16
17
|
end
|
17
18
|
|
18
19
|
def report
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
20
|
+
message = "#{run_status.formatted_exception}\n"
|
21
|
+
message << Array(backtrace).join("\n")
|
22
|
+
|
23
|
+
if STDOUT.tty?
|
24
|
+
Chef::Log.error("Chef run failed @ #{@timestamp}")
|
25
|
+
puts message
|
26
|
+
else
|
27
|
+
Chef::Log.error("Chef run failed @ #{@timestamp}, snitchin' to chefs via IRC")
|
28
|
+
|
29
|
+
gist_id = nil
|
30
|
+
|
31
|
+
begin
|
32
|
+
timeout(10) do
|
33
|
+
res = Net::HTTP.post_form(URI.parse("http://gist.github.com/api/v1/json/new"), {
|
34
|
+
"files[#{node.name}-#{@timestamp.to_i.to_s}]" => message,
|
35
|
+
"login" => @github_user,
|
36
|
+
"token" => @github_token,
|
37
|
+
"description" => "Chef run failed on #{node.name} @ #{@timestamp}",
|
38
|
+
"public" => false
|
39
|
+
})
|
40
|
+
gist_id = JSON.parse(res.body)["gists"].first["repo"]
|
41
|
+
Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}")
|
42
|
+
end
|
43
|
+
rescue Timeout::Error
|
44
|
+
Chef::Log.error("Timed out while attempting to create a GitHub Gist")
|
38
45
|
end
|
39
|
-
rescue Timeout::Error
|
40
|
-
Chef::Log.error("Timed out while attempting to create a GitHub Gist, retrying ...")
|
41
|
-
max_attempts -= 1
|
42
|
-
retry if max_attempts > 0
|
43
|
-
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
message = "Chef run failed on #{node.name} : #{ip_address} : #{node.roles.join(", ")} : https://gist.github.com/#{gist_id}"
|
47
|
+
ip_address = (node.has_key? :ec2) ? node.ec2.public_ipv4 : node.ipaddress
|
48
|
+
message = "Chef run failed on #{node.name} : #{ip_address} : #{node.roles.join(", ")} : https://gist.github.com/#{gist_id}"
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
begin
|
51
|
+
timeout(10) do
|
52
|
+
CarrierPigeon.send(:uri => @irc_uri, :message => message, :ssl => @ssl)
|
53
|
+
Chef::Log.info("Informed chefs via IRC '#{message}'")
|
54
|
+
end
|
55
|
+
rescue Timeout::Error
|
56
|
+
Chef::Log.error("Timed out while attempting to message Chefs via IRC")
|
53
57
|
end
|
54
|
-
rescue Timeout::Error
|
55
|
-
Chef::Log.error("Timed out while attempting to message Chefs via IRC, retrying ...")
|
56
|
-
max_attempts -= 1
|
57
|
-
retry if max_attempts > 0
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: chef-irc-snitch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Porter
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-08-24 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: chef
|
@@ -52,7 +51,6 @@ files:
|
|
52
51
|
- Rakefile
|
53
52
|
- chef-irc-snitch.gemspec
|
54
53
|
- lib/chef-irc-snitch.rb
|
55
|
-
has_rdoc: true
|
56
54
|
homepage: https://github.com/portertech/chef-irc-snitch
|
57
55
|
licenses:
|
58
56
|
- MIT
|
@@ -76,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
74
|
requirements: []
|
77
75
|
|
78
76
|
rubyforge_project: chef-irc-snitch
|
79
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 1.8.8
|
80
78
|
signing_key:
|
81
79
|
specification_version: 3
|
82
80
|
summary: An exception handler for OpsCode Chef runs (GitHub Gists & IRC)
|