cycle_chef_handler 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +3 -2
- data/lib/cycle_chef_handler.rb +43 -14
- metadata +4 -4
data/README.txt
CHANGED
@@ -18,12 +18,13 @@ reports for the CycleServer Chef Dashboard available from Cycle Computing LLC.
|
|
18
18
|
== INSTALL:
|
19
19
|
|
20
20
|
* sudo gem install cycle_chef_handler
|
21
|
-
* edit /etc/chef/client.rb on client nodes
|
21
|
+
* edit /etc/chef/client.rb on client nodes
|
22
|
+
|
23
|
+
Example
|
22
24
|
|
23
25
|
require 'cycle_chef_handler'
|
24
26
|
|
25
27
|
handler = CycleChefHandler.new(:amqp_config => {:host => 'my_amqp_hostname'})
|
26
|
-
|
27
28
|
report_handlers << handler
|
28
29
|
exception_handlers << handler
|
29
30
|
|
data/lib/cycle_chef_handler.rb
CHANGED
@@ -26,22 +26,29 @@ require 'fileutils'
|
|
26
26
|
require 'uri'
|
27
27
|
|
28
28
|
class CycleChefHandler < Chef::Handler
|
29
|
-
VERSION = '1.2.
|
29
|
+
VERSION = '1.2.1'
|
30
30
|
|
31
31
|
def initialize(params)
|
32
|
-
defaults = {:
|
33
|
-
:
|
32
|
+
defaults = {:exchange => 'chef',
|
33
|
+
:exchange_type => :direct,
|
34
|
+
:exchange_durable => false,
|
35
|
+
:exchange_autodelete => false,
|
36
|
+
:bind_queue => false,
|
37
|
+
:queue => nil,
|
38
|
+
:queue_durable => false,
|
39
|
+
:queue_autodelete => true,
|
40
|
+
:routing_key => 'chef'}
|
34
41
|
|
35
42
|
@amqp_config = defaults.merge(params[:amqp_config])
|
36
43
|
check_amqp_config
|
37
44
|
|
38
|
-
@extras = params[:extras]
|
45
|
+
@extras = params[:extras] || {}
|
39
46
|
@converge_index_file = params[:converge_index_file] || '/var/run/chef/converge_index'
|
40
47
|
@failed_converge_file = params[:failed_converge_count_file] || '/var/run/chef/failed_converge_count'
|
41
48
|
end
|
42
49
|
|
43
50
|
def check_amqp_config
|
44
|
-
[:host, :
|
51
|
+
[:host, :exchange].each do |i|
|
45
52
|
if not @amqp_config[i]
|
46
53
|
raise ArgumentError, ":amqp_config missing value for #{i}"
|
47
54
|
end
|
@@ -60,17 +67,39 @@ class CycleChefHandler < Chef::Handler
|
|
60
67
|
|
61
68
|
b.start
|
62
69
|
e = b.exchange(@amqp_config[:exchange],
|
63
|
-
:type
|
64
|
-
:durable
|
65
|
-
:auto_delete =>
|
70
|
+
:type => @amqp_config[:exchange_type],
|
71
|
+
:durable => @amqp_config[:exchange_durable],
|
72
|
+
:auto_delete => @amqp_config[:exchange_autodelete])
|
66
73
|
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
|
71
|
-
|
74
|
+
# in some cases, the user may want to declare and bind a queue
|
75
|
+
# to the exchange so consumers get all messages, even ones that
|
76
|
+
# enter the exchange before the consumer exists.
|
77
|
+
if @amqp_config[:bind_queue]
|
78
|
+
q = b.queue(@amqp_config[:queue],
|
79
|
+
:durable => @amqp_config[:queue_durable],
|
80
|
+
:auto_delete => @amqp_config[:queue_autodelete])
|
72
81
|
|
73
|
-
|
82
|
+
if not @amqp_config[:routing_key].nil?
|
83
|
+
|
84
|
+
q.bind(@amqp_config[:exchange], :key => @amqp_config[:routing_key])
|
85
|
+
|
86
|
+
else
|
87
|
+
|
88
|
+
q.bind(@amqp_config[:exchange])
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
if not @amqp_config[:routing_key].nil?
|
95
|
+
|
96
|
+
e.publish(payload, :key => @amqp_config[:routing_key])
|
97
|
+
|
98
|
+
else
|
99
|
+
|
100
|
+
e.publish(payload)
|
101
|
+
|
102
|
+
end
|
74
103
|
|
75
104
|
rescue Exception => e
|
76
105
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cycle_chef_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Chalfant
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: chef
|