chef-handler-opsmatic 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2771ed4836a7f21ab86a7f5df7cca8cd7cec697
4
- data.tar.gz: 416cf114a34b2dbae865e79c3eaaddc3b4712fda
3
+ metadata.gz: 8a562b904019bd72a925c7ac5226c4efc6cfbc6b
4
+ data.tar.gz: 51145420def18bc1f6a858a2cceeca2a35ef9fd9
5
5
  SHA512:
6
- metadata.gz: d6ef7a5f3f53896745046bcf8c567f4ac674d8cb9b191edf8b59700343536cfa33c399ed217012206d7c0847b659ac4c8ed8303f6fb430c7fa81a5844422719b
7
- data.tar.gz: fc56b7315485796b11834d874513d60083dbefeb9814c45a58ff9aa43ee6031cb6be63e7e164b85fea071a69b70d93d9e4b16b3b38a26d3324f18fe8d2eca85d
6
+ metadata.gz: 16093dcac89d2099c0bc012f193824a15715edf54c170f0154640d0e2b82fd3290a97f8a4bded75adec5bdeb74734255af0a649044460816bb3415382fcb42ec
7
+ data.tar.gz: f9083ea089c21ed46f99b4d0a1c4a37892b580d73e9e37697db557f00292348d52a16b4dea276adbdc6c45962192a9a0a49a1892f1829f5460dd6bdebe847fd1
@@ -74,8 +74,8 @@ class Chef
74
74
  # submit our event
75
75
  submit opsmatic_event
76
76
 
77
- # write the node attributes to a json file for the agent
78
- write_attributes
77
+ # write the node attributes and cookbook versions to json files for the agent
78
+ write_metadata
79
79
  end
80
80
 
81
81
  # collects up details on file resources managed by chef on the host and writes
@@ -182,7 +182,7 @@ class Chef
182
182
  end
183
183
  end
184
184
 
185
- def write_attributes()
185
+ def write_metadata()
186
186
  ext_dir = "#{@config[:agent_dir]}/user_data/metadata"
187
187
  unless File.exists?(ext_dir)
188
188
  FileUtils.mkdir_p(ext_dir)
@@ -190,10 +190,10 @@ class Chef
190
190
 
191
191
  begin
192
192
  node_json = Chef::JSONCompat.to_json_pretty(data[:node])
193
- hash = JSON.parse(node_json)
194
- hash.delete("automatic")
195
- hash["opsmatic_event_category"] = "automation"
196
- file_json = hash.to_json
193
+ node_hash = JSON.parse(node_json)
194
+ node_hash.delete("automatic")
195
+ node_hash["opsmatic_event_category"] = "automation"
196
+ attribute_json = node_hash.to_json
197
197
  rescue Exception => msg
198
198
  Chef::Log.warn("An unhandled execption while preparing to write node data: #{msg}")
199
199
  return
@@ -202,13 +202,35 @@ class Chef
202
202
  begin
203
203
  filename = File.join(ext_dir, "chef_attributes.json")
204
204
  File.open(filename, "w") do |file|
205
- file.puts file_json
205
+ file.puts attribute_json
206
206
  end
207
207
  rescue Exception => msg
208
208
  Chef::Log.warn("An unhandled execption while writing to #{filename}: #{msg}")
209
209
  return
210
210
  end
211
+
212
+ begin
213
+ cookbook_hash = {}
214
+ run_context.cookbook_collection.keys.each do |name|
215
+ cookbook_hash[name] = run_context.cookbook_collection[name].version
216
+ end
217
+ cookbook_hash["opsmatic_event_category"] = "automation"
218
+ rescue Exception => msg
219
+ Chef::Log.warn("An unhandled execption while preparing to write cookbook data: #{msg}")
220
+ return
221
+ end
222
+
223
+ begin
224
+ filename = File.join(ext_dir, "chef_cookbooks.json")
225
+ File.open(filename, "w") do |file|
226
+ file.puts cookbook_hash.to_json
227
+ end
228
+ rescue Exception => msg
229
+ Chef::Log.warn("An unhandled execption while writing to #{filename}: #{msg}")
230
+ return
231
+ end
232
+
211
233
  end
212
234
  end
213
235
  end
214
- end
236
+ end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  class Handler
3
3
  class Opsmatic < ::Chef::Handler
4
- VERSION = "0.0.17"
4
+ VERSION = "0.0.18"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-handler-opsmatic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Opsmatic Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,4 +124,3 @@ summary: Chef report handler for sending run detail information to Opsmatic
124
124
  test_files:
125
125
  - spec/opsmatic_spec.rb
126
126
  - spec/spec_helper.rb
127
- has_rdoc: