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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "chef-irc-snitch"
3
- s.version = "0.0.7"
3
+ s.version = "0.0.8"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ["Sean Porter"]
6
6
  s.email = ["portertech@gmail.com"]
@@ -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
- Chef::Log.error("Chef run failed @ #{Time.now.getutc}, snitchin' to chefs via IRC")
20
-
21
- gist = "#{run_status.formatted_exception}\n"
22
- gist << Array(backtrace).join("\n")
23
-
24
- max_attempts = 2
25
- gist_id = nil
26
-
27
- begin
28
- timeout(8) do
29
- res = Net::HTTP.post_form(URI.parse("http://gist.github.com/api/v1/json/new"), {
30
- "files[#{node.name}-#{Time.now.to_i.to_s}]" => gist,
31
- "login" => @github_user,
32
- "token" => @github_token,
33
- "description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}",
34
- "public" => false
35
- })
36
- gist_id = JSON.parse(res.body)["gists"].first["repo"]
37
- Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}")
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
- max_attempts = 2
46
- ip_address = (node.has_key? :ec2) ? node.ec2.public_ipv4 : node.ipaddress
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
- begin
50
- timeout(8) do
51
- CarrierPigeon.send(:uri => @irc_uri, :message => message, :ssl => @ssl)
52
- Chef::Log.info("Informed chefs via IRC : #{message}")
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.7
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-07 00:00:00 -07:00
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.6.2
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)