chef-irc-snitch 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/chef-irc-snitch.gemspec +26 -0
- data/lib/chef-irc-snitch/version.rb +7 -0
- data/lib/chef-irc-snitch.rb +52 -0
- metadata +83 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "chef-irc-snitch/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "chef-irc-snitch"
|
7
|
+
s.version = Chef::IRC::Snitch::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Sean Porter"]
|
10
|
+
s.email = ["portertech@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/portertech/chef-irc-snitch"
|
12
|
+
s.summary = %q{An exception handler for OpsCode Chef runs (GitHub Gists & IRC)}
|
13
|
+
s.description = %q{An exception handler for OpsCode Chef runs (GitHub Gists & IRC)}
|
14
|
+
s.has_rdoc = false
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.rubyforge_project = "chef-irc-snitch"
|
18
|
+
|
19
|
+
s.add_dependency('chef')
|
20
|
+
s.add_dependency('shout-bot')
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'chef'
|
3
|
+
require 'chef/handler'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
require 'json'
|
7
|
+
require 'shout-bot'
|
8
|
+
|
9
|
+
class IRCSnitch < Chef::Handler
|
10
|
+
|
11
|
+
def initialize(irc_uri, github_user, github_token)
|
12
|
+
@irc_uri = irc_uri
|
13
|
+
@github_user = github_user
|
14
|
+
@github_token = github_token
|
15
|
+
end
|
16
|
+
|
17
|
+
def report
|
18
|
+
Chef::Log.error("Chef run failed @ #{Time.now.getutc}, snitchin' to chefs via IRC")
|
19
|
+
|
20
|
+
gist = "#{run_status.formatted_exception}\n\n"
|
21
|
+
gist << Array(backtrace).join("\n")
|
22
|
+
|
23
|
+
max_attempts = 3
|
24
|
+
gist_id = nil
|
25
|
+
|
26
|
+
begin
|
27
|
+
timeout(8) do
|
28
|
+
res = Net::HTTP.post_form(URI.parse("http://gist.github.com/api/v1/json/new"), {
|
29
|
+
"files[#{node.name}-#{Time.now.to_i.to_s}]" => gist,
|
30
|
+
"login" => @github_user,
|
31
|
+
"token" => @github_token,
|
32
|
+
"description" => "Chef run failed on #{node.name} @ #{Time.now.getutc}"
|
33
|
+
})
|
34
|
+
gist_id = JSON.parse(res.body)["gists"].first["repo"]
|
35
|
+
end
|
36
|
+
rescue Timeout::Error
|
37
|
+
Chef::Log.info("Timed out while attempting to create a GitHub Gist, retrying ...")
|
38
|
+
max_attempts -= 1
|
39
|
+
retry if max_attempts > 0
|
40
|
+
end
|
41
|
+
|
42
|
+
Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}")
|
43
|
+
|
44
|
+
message = "Chef run failed on #{node.name} => https://gist.github.com/#{gist_id}"
|
45
|
+
|
46
|
+
ShoutBot.shout(@irc_uri) do |channel|
|
47
|
+
channel.say message
|
48
|
+
Chef::Log.info("Informed chefs via IRC => '#{message}'")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-irc-snitch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sean Porter
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-31 00:00:00 +09:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: chef
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shout-bot
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: An exception handler for OpsCode Chef runs (GitHub Gists & IRC)
|
39
|
+
email:
|
40
|
+
- portertech@gmail.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Rakefile
|
51
|
+
- chef-irc-snitch.gemspec
|
52
|
+
- lib/chef-irc-snitch.rb
|
53
|
+
- lib/chef-irc-snitch/version.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: https://github.com/portertech/chef-irc-snitch
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: chef-irc-snitch
|
78
|
+
rubygems_version: 1.6.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: An exception handler for OpsCode Chef runs (GitHub Gists & IRC)
|
82
|
+
test_files: []
|
83
|
+
|