genesis_collector 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/genesis_collector/chef.rb +22 -14
- data/lib/genesis_collector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7380d9cdffa045595133ceaf1058548d805690ef
|
4
|
+
data.tar.gz: 263298738b9ce230963da716696f27e78af66b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb446358887fd25740f07fc624536a2ca5c82c9d1f909138af494785c2d66f0c3390bd8ab71773e3d88b10c4301e77c59300af3989d66d187d30c110414dbaa
|
7
|
+
data.tar.gz: 108a96d5a92935b1b8debd9f1fcd7ab4d101fd80618b3986cbb856a93c56ef3377c84c972eb30afc371f2485bbe02773f724f540cea58727f8dd1c0a45237a76
|
@@ -1,26 +1,34 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
1
3
|
module GenesisCollector
|
2
4
|
module Chef
|
3
5
|
|
4
6
|
def collect_chef
|
5
|
-
@payload[:chef] =
|
6
|
-
environment: get_chef_environment,
|
7
|
-
roles: (@chef_node.respond_to?(:[]) ? @chef_node['roles'] : []),
|
8
|
-
run_list: (@chef_node.respond_to?(:[]) ? @chef_node['run_list'] : ''),
|
9
|
-
tags: get_chef_tags
|
10
|
-
}
|
7
|
+
@payload[:chef] = @chef_node.nil? ? collect_chef_from_knife : collect_chef_from_node
|
11
8
|
end
|
12
9
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
def collect_chef_from_node
|
11
|
+
{
|
12
|
+
environment: @chef_node.chef_environment,
|
13
|
+
roles: @chef_node.roles,
|
14
|
+
run_list: @chef_node.run_list.to_s,
|
15
|
+
tags: @chef_node.tags,
|
16
|
+
last_run: Time.at(@chef_node.ohai_time).utc.iso8601
|
17
|
+
}
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
20
|
+
def collect_chef_from_knife
|
21
|
+
output = shellout_with_timeout('knife node show `hostname` -c /etc/chef/client.rb -a ohai_time -a run_list -a tags -a environment -a roles -f json')
|
22
|
+
_hostname, parsed = JSON.parse(output).first
|
23
|
+
{
|
24
|
+
environment: parsed['environment'],
|
25
|
+
roles: parsed['roles'],
|
26
|
+
run_list: parsed['run_list'].join(', '),
|
27
|
+
tags: parsed['tags'],
|
28
|
+
last_run: Time.at(parsed['ohai_time']).utc.iso8601
|
29
|
+
}
|
22
30
|
rescue
|
23
|
-
|
31
|
+
nil
|
24
32
|
end
|
25
33
|
|
26
34
|
end
|