chef-handler-opsmatic 0.0.17 → 0.0.18
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.
- checksums.yaml +4 -4
- data/lib/chef/handler/opsmatic.rb +31 -9
- data/lib/chef/handler/opsmatic_version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a562b904019bd72a925c7ac5226c4efc6cfbc6b
|
4
|
+
data.tar.gz: 51145420def18bc1f6a858a2cceeca2a35ef9fd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
78
|
-
|
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
|
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
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
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
|
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.
|
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-
|
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:
|