chef-irc-snitch 0.0.9 → 0.0.10
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/README.org +3 -3
- data/chef-irc-snitch.gemspec +1 -1
- data/lib/chef-irc-snitch.rb +11 -11
- metadata +4 -4
data/README.org
CHANGED
@@ -6,17 +6,17 @@
|
|
6
6
|
|
7
7
|
** Configure Chef to Use The Handler
|
8
8
|
|
9
|
-
Append the following to your Chef client configs
|
9
|
+
Append the following to your Chef client configs, usually at =/etc/chef/client.rb=
|
10
10
|
|
11
11
|
: # Notify admins via IRC when a Chef run fails
|
12
12
|
: require 'chef-irc-snitch'
|
13
13
|
:
|
14
14
|
: irc_uri = "irc://nick:password@irc.domain.com:6667/#admins"
|
15
15
|
: github_user = "foobar"
|
16
|
-
:
|
16
|
+
: github_password = "secret"
|
17
17
|
: enable_ssl = true
|
18
18
|
:
|
19
|
-
: irc_handler = IRCSnitch.new(irc_uri, github_user,
|
19
|
+
: irc_handler = IRCSnitch.new(irc_uri, github_user, github_password, enable_ssl)
|
20
20
|
: exception_handlers << irc_handler
|
21
21
|
|
22
22
|
* License
|
data/chef-irc-snitch.gemspec
CHANGED
data/lib/chef-irc-snitch.rb
CHANGED
@@ -8,26 +8,26 @@ require 'carrier-pigeon'
|
|
8
8
|
|
9
9
|
class IRCSnitch < Chef::Handler
|
10
10
|
|
11
|
-
def initialize(irc_uri, github_user,
|
11
|
+
def initialize(irc_uri, github_user, github_password, ssl = false)
|
12
12
|
@irc_uri = irc_uri
|
13
13
|
@github_user = github_user
|
14
|
-
@
|
14
|
+
@github_password = github_password
|
15
15
|
@ssl = ssl
|
16
16
|
@timestamp = Time.now.getutc
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def formatted_run_list
|
20
20
|
node.run_list.map {|r| r.type == :role ? r.name : r.to_s }.join(', ')
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def formatted_gist
|
24
24
|
([ "Node: #{node.name} (#{node.ipaddress})",
|
25
25
|
"Run list: #{node.run_list}",
|
26
26
|
"All roles: #{node.roles.join(', ')}",
|
27
27
|
"",
|
28
28
|
"#{run_status.formatted_exception}",
|
29
|
-
""
|
30
|
-
Array(backtrace)).join("\n")
|
29
|
+
""
|
30
|
+
] + Array(backtrace)).join("\n")
|
31
31
|
end
|
32
32
|
|
33
33
|
def report
|
@@ -41,21 +41,21 @@ class IRCSnitch < Chef::Handler
|
|
41
41
|
gist_id = nil
|
42
42
|
begin
|
43
43
|
timeout(10) do
|
44
|
-
|
45
|
-
"files[#{node.name}-#{@timestamp.to_i
|
44
|
+
response = Net::HTTP.post_form(URI.parse("http://gist.github.com/api/v1/json/new"), {
|
45
|
+
"files[#{node.name}-#{@timestamp.to_i}]" => formatted_gist,
|
46
46
|
"login" => @github_user,
|
47
|
-
"
|
47
|
+
"password" => @github_password,
|
48
48
|
"description" => "Chef run failed on #{node.name} @ #{@timestamp}",
|
49
49
|
"public" => false
|
50
50
|
})
|
51
|
-
gist_id = JSON.parse(
|
51
|
+
gist_id = JSON.parse(response.body)["gists"].first["repo"]
|
52
52
|
Chef::Log.info("Created a GitHub Gist @ https://gist.github.com/#{gist_id}")
|
53
53
|
end
|
54
54
|
rescue Timeout::Error
|
55
55
|
Chef::Log.error("Timed out while attempting to create a GitHub Gist")
|
56
56
|
end
|
57
57
|
|
58
|
-
message = "Chef failed on #{node.name} (#{
|
58
|
+
message = "Chef failed on #{node.name} (#{formatted_run_list}): https://gist.github.com/#{gist_id}"
|
59
59
|
|
60
60
|
begin
|
61
61
|
timeout(10) do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-irc-snitch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Porter
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-04-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|