ohai 8.0.1 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +13 -5
  2. data/lib/ohai/loader.rb +1 -1
  3. data/lib/ohai/mixin/gce_metadata.rb +2 -1
  4. data/lib/ohai/plugins/cloud.rb +56 -6
  5. data/lib/ohai/plugins/cloud_v2.rb +29 -1
  6. data/lib/ohai/plugins/cloudstack.rb +7 -0
  7. data/lib/ohai/plugins/digital_ocean.rb +81 -0
  8. data/lib/ohai/plugins/elixir.rb +32 -0
  9. data/lib/ohai/plugins/linode.rb +1 -0
  10. data/lib/ohai/plugins/linux/block_device.rb +5 -0
  11. data/lib/ohai/plugins/linux/cpu.rb +21 -1
  12. data/lib/ohai/plugins/linux/filesystem.rb +1 -1
  13. data/lib/ohai/plugins/linux/network.rb +6 -2
  14. data/lib/ohai/plugins/linux/platform.rb +2 -0
  15. data/lib/ohai/plugins/linux/virtualization.rb +14 -3
  16. data/lib/ohai/plugins/php.rb +13 -6
  17. data/lib/ohai/plugins/ruby.rb +10 -10
  18. data/lib/ohai/plugins/rust.rb +32 -0
  19. data/lib/ohai/plugins/ssh_host_key.rb +6 -0
  20. data/lib/ohai/util/ip_helper.rb +52 -0
  21. data/lib/ohai/version.rb +1 -1
  22. data/spec/data/plugins/php.output +16 -0
  23. data/spec/unit/plugins/cloud_spec.rb +63 -9
  24. data/spec/unit/plugins/cloud_v2_spec.rb +123 -25
  25. data/spec/unit/plugins/cloudstack_spec.rb +1 -1
  26. data/spec/unit/plugins/digital_ocean_spec.rb +211 -0
  27. data/spec/unit/plugins/elixir_spec.rb +46 -0
  28. data/spec/unit/plugins/linux/cpu_spec.rb +112 -35
  29. data/spec/unit/plugins/linux/filesystem_spec.rb +7 -7
  30. data/spec/unit/plugins/linux/network_spec.rb +63 -4
  31. data/spec/unit/plugins/linux/platform_spec.rb +13 -0
  32. data/spec/unit/plugins/linux/virtualization_spec.rb +146 -21
  33. data/spec/unit/plugins/php_spec.rb +37 -3
  34. data/spec/unit/plugins/rust_spec.rb +43 -0
  35. data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -0
  36. data/spec/unit/util/ip_helper_spec.rb +128 -0
  37. metadata +49 -41
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0d9d3f875c58cc677e9188ec2183e25de5911e3e
4
- data.tar.gz: fb59c6094438728c98ff3a9f2c9d4420579096dc
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTMxZTg2ZjdiNDBiZDMwMWNjYjUwZDc5OTI3ZGFhZmIxZDcxZWMxOA==
5
+ data.tar.gz: !binary |-
6
+ MmFlODM1NWNiYjVhNzAyODdhY2IxMWM4OGNjZjFkY2YxY2E2NDdmOQ==
5
7
  SHA512:
6
- metadata.gz: eab2a721b93ce4e9ccce9d4fce5fec55c191def267ee2ed713f0a859050ea1d4a59b0d583182475669408a3636ca2df3aa2890b7cff49401813220eb476c9e4f
7
- data.tar.gz: f076c97eb34c8c66361dfdecb4fd3e418ca367494fcfc025a2c033f046949b64e850304ccd63519699c3b3e20c07acb8b2c7a043a0e99d9454951f3d016adb1d
8
+ metadata.gz: !binary |-
9
+ ZjM4Y2YyYWRiYmZmZmYxOTlmMjBjODAxM2VmMWYxOGYyYzQ2NTM3NWM4ZTM3
10
+ OTIwZGVjM2U2YmRhZWQ2ZWZiMjcyMDg0ZmZiZGMxZjliOGIzMDNiY2Q1MmY0
11
+ ODdlYWIzZTkwMmFlMWE1NWM5NTY3NjIyY2M3NWM4Y2U2MjgwZWU=
12
+ data.tar.gz: !binary |-
13
+ YjI3ZWYzOGQ3N2Y5OWM2ZDc5NzNlYWYxYzVhYmM5NmExZTI0MTAyNjMzZDEw
14
+ Mzg1YmEyZjdmZTA4MTMyMDA4ZjdiMDkxZTMxMzE2ZjY1Mzc5ZWUyMTI3Yjcy
15
+ ZDI1YWY2ZmFlY2E5MjVkMTYxOWE3MmI2ODBhODhmNzVmNDE1YzQ=
@@ -111,7 +111,7 @@ module Ohai
111
111
  Ohai::Log.warn("[DEPRECATION] Plugin at #{plugin_path} is a version 6 plugin. \
112
112
  Version 6 plugins will not be supported in future releases of Ohai. \
113
113
  Please upgrade your plugin to version 7 plugin syntax. \
114
- For more information visit here: docs.opscode.com/ohai_custom.html")
114
+ For more information visit here: docs.chef.io/ohai_custom.html")
115
115
 
116
116
  load_v6_plugin_class(contents, plugin_path, plugin_dir_path)
117
117
  end
@@ -21,7 +21,8 @@ module Ohai
21
21
  module Mixin
22
22
  module GCEMetadata
23
23
 
24
- GCE_METADATA_ADDR = "metadata.google.internal" unless defined?(GCE_METADATA_ADDR)
24
+ # Trailing dot to host is added to avoid DNS search path
25
+ GCE_METADATA_ADDR = "metadata.google.internal." unless defined?(GCE_METADATA_ADDR)
25
26
  GCE_METADATA_URL = "/computeMetadata/v1beta1/?recursive=true" unless defined?(GCE_METADATA_URL)
26
27
 
27
28
  def can_metadata_connect?(addr, port, timeout=2)
@@ -25,6 +25,7 @@ Ohai.plugin(:Cloud) do
25
25
  depends "openstack"
26
26
  depends "azure"
27
27
  depends "cloudstack"
28
+ depends "digital_ocean"
28
29
 
29
30
  # Make top-level cloud hashes
30
31
  #
@@ -229,16 +230,59 @@ Ohai.plugin(:Cloud) do
229
230
  cloudstack != nil
230
231
  end
231
232
 
232
- # Fill cloud hash with cloudstack values
233
+ # Fill cloud hash with cloudstack values. Cloudstack is a bit different in that
234
+ # the local interface can be a public or private ip is using basic networking.
235
+ # When using advanced networking, the public_ipv4 passed in the metadata isn't
236
+ # usually going to be the public ip of the interface, so don't use that value. As
237
+ # per the Cloudstack documentation its actually the NAT router IP.
233
238
  def get_cloudstack_values
234
- cloud[:public_ips] << cloudstack['public_ipv4']
235
- cloud[:private_ips] << cloudstack['local_ipv4']
236
- cloud[:public_ipv4] = cloudstack['public_ipv4']
237
- cloud[:public_hostname] = cloudstack['public_hostname']
238
239
  cloud[:local_ipv4] = cloudstack['local_ipv4']
240
+
241
+ if cloudstack['local_ipv4']
242
+ # Private IPv4 address
243
+ if cloudstack['local_ipv4'] =~ /\A(10\.|192\.168\.|172\.1[6789]\.|172\.2.\.|172\.3[01]\.)/
244
+ cloud[:private_ips] << cloudstack['local_ipv4']
245
+ cloud[:public_ipv4] = nil
246
+ else
247
+ cloud[:public_ips] << cloudstack['local_ipv4']
248
+ # Yes, not a mistake, for basic networking this may be true
249
+ cloud[:public_ipv4] = cloudstack['local_ipv4']
250
+ end
251
+ end
252
+ cloud[:public_hostname] = cloudstack['public_hostname']
239
253
  cloud[:local_hostname] = cloudstack['local_hostname']
240
254
  cloud[:vm_id] = cloudstack['vm_id']
241
- cloud[:provider] = "cloudstack"
255
+ cloud[:local_hostname] = cloudstack['local_hostname']
256
+ cloud[:provider] = 'cloudstack'
257
+ end
258
+
259
+ # ----------------------------------------
260
+ # digital_ocean
261
+ # ----------------------------------------
262
+
263
+ # Is current cloud digital_ocean?
264
+ #
265
+ # === Return
266
+ # true:: If digital_ocean Mash is defined
267
+ # false:: Otherwise
268
+ def on_digital_ocean?
269
+ digital_ocean != nil
270
+ end
271
+
272
+ # Fill cloud hash with linode values
273
+ def get_digital_ocean_values
274
+ public_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'public'}
275
+ private_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'private'}
276
+ public_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'public'}
277
+ private_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'private'}
278
+ cloud[:public_ips].concat public_ipv4+public_ipv6
279
+ cloud[:private_ips].concat private_ipv4+private_ipv6
280
+ cloud[:public_ipv4] = public_ipv4.first
281
+ cloud[:public_ipv6] = public_ipv6.first
282
+ cloud[:local_ipv4] = private_ipv4.first
283
+ cloud[:local_ipv6] = private_ipv6.first
284
+ cloud[:public_hostname] = digital_ocean['name']
285
+ cloud[:provider] = "digital_ocean"
242
286
  end
243
287
 
244
288
  collect_data do
@@ -288,5 +332,11 @@ Ohai.plugin(:Cloud) do
288
332
  create_objects
289
333
  get_cloudstack_values
290
334
  end
335
+
336
+ # setup digital_ocean cloud data
337
+ if on_digital_ocean?
338
+ create_objects
339
+ get_digital_ocean_values
340
+ end
291
341
  end
292
342
  end
@@ -24,6 +24,7 @@ Ohai.plugin(:CloudV2) do
24
24
  depends "linode"
25
25
  depends "openstack"
26
26
  depends "azure"
27
+ depends "digital_ocean"
27
28
 
28
29
  # Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
29
30
  #
@@ -124,7 +125,7 @@ Ohai.plugin(:CloudV2) do
124
125
  def get_gce_values
125
126
  public_ips = gce['instance']['networkInterfaces'].collect do |interface|
126
127
  if interface.has_key?('accessConfigs')
127
- interface['accessConfigs'].collect{|ac| ac['externalIp']}
128
+ interface['accessConfigs'].collect{|ac| ac['externalIp'] unless ac['externalIp'] == ''}
128
129
  end
129
130
  end.flatten.compact
130
131
 
@@ -270,6 +271,32 @@ Ohai.plugin(:CloudV2) do
270
271
  @cloud_attr_obj.provider = "azure"
271
272
  end
272
273
 
274
+
275
+ # ----------------------------------------
276
+ # digital_ocean
277
+ # ----------------------------------------
278
+
279
+ # Is current cloud digital_ocean?
280
+ #
281
+ # === Return
282
+ # true:: If digital_ocean Mash is defined
283
+ # false:: Otherwise
284
+ def on_digital_ocean?
285
+ digital_ocean != nil
286
+ end
287
+
288
+ # Fill cloud hash with digital_ocean values
289
+ def get_digital_ocean_values
290
+ digital_ocean['networks'].each do |network, addresses|
291
+ type = network == 'v4' ? 'ipv4' : 'ipv6'
292
+ addresses.each do |address|
293
+ @cloud_attr_obj.send("add_#{type}_addr", address['ip_address'], address['type'].to_sym)
294
+ end
295
+ end
296
+ @cloud_attr_obj.public_hostname = digital_ocean['name']
297
+ @cloud_attr_obj.provider = "digital_ocean"
298
+ end
299
+
273
300
  collect_data do
274
301
  require "ipaddr"
275
302
 
@@ -282,6 +309,7 @@ Ohai.plugin(:CloudV2) do
282
309
  get_eucalyptus_values if on_eucalyptus?
283
310
  get_openstack_values if on_openstack?
284
311
  get_azure_values if on_azure?
312
+ get_digital_ocean_values if on_digital_ocean?
285
313
 
286
314
  # set node[:cloud] hash here
287
315
  cloud_v2 @cloud_attr_obj.cloud_mash
@@ -1,5 +1,7 @@
1
1
  #
2
+ # Author:: Peter Schroeter <peter.schroeter@rightscale.com>
2
3
  # Author:: Olle Lundberg (<geek@nerd.sh>)
4
+ # Copyright:: Copyright (c) 2010-2014 RightScale Inc
3
5
  # Copyright:: Copyright (c) 2014 Opscode, Inc.
4
6
  # License:: Apache License, Version 2.0
5
7
  #
@@ -31,6 +33,11 @@ Ohai.plugin(:Cloudstack) do
31
33
  cloudstack Mash.new
32
34
  Ohai::Log.debug("connecting to the 'cloudstack' metadata service")
33
35
  fetch_metadata.each { |k, v| cloudstack[k] = v }
36
+ # Note: the cloudstack public_ipv4 is the value of the NAT router (as per cloudstack documentation)
37
+ # and not necessarily the publicly available IP. cloustack semi-supports floating
38
+ # ips in that the public ip for an instance can be an IP different from the NAT router
39
+ cloudstack['router_ipv4'] = cloudstack.delete('public_ipv4')
40
+ cloudstack['dhcp_lease_provider_ip'] = dhcp_ip
34
41
  else
35
42
  Ohai::Log.debug("unable to connect to the 'cloudstack' metadata service")
36
43
  end
@@ -0,0 +1,81 @@
1
+ #
2
+ # Author:: Stafford Brunk (<stafford.brunk@gmail.com>)
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'ohai/util/ip_helper'
18
+
19
+ Ohai.plugin(:DigitalOcean) do
20
+ include Ohai::Util::IpHelper
21
+
22
+ DIGITALOCEAN_FILE = '/etc/digitalocean'
23
+
24
+ provides "digital_ocean"
25
+
26
+ depends "network/interfaces"
27
+
28
+ def extract_droplet_ip_addresses
29
+ addresses = Mash.new({'v4' => [], 'v6' => []})
30
+ network[:interfaces].each_value do |iface|
31
+ iface[:addresses].each do |address, details|
32
+ next if loopback?(address) || details[:family] == 'lladdr'
33
+
34
+ ip = IPAddress(address)
35
+ type = digital_ocean_address_type(ip)
36
+ address_hash = build_address_hash(ip, details)
37
+ addresses[type] << address_hash
38
+ end
39
+ end
40
+ addresses
41
+ end
42
+
43
+ def build_address_hash(ip, details)
44
+ address_hash = Mash.new({
45
+ 'ip_address' => ip.address,
46
+ 'type' => private_address?(ip.address) ? 'private' : 'public'
47
+ })
48
+
49
+ if ip.ipv4?
50
+ address_hash['netmask'] = details[:netmask]
51
+ elsif ip.ipv6?
52
+ address_hash['cidr'] = ip.prefix
53
+ end
54
+ address_hash
55
+ end
56
+
57
+ def digital_ocean_address_type(ip)
58
+ ip.ipv4? ? 'v4' : 'v6'
59
+ end
60
+
61
+ def looks_like_digital_ocean?
62
+ hint?('digital_ocean') || File.exist?(DIGITALOCEAN_FILE)
63
+ end
64
+
65
+ collect_data do
66
+ if looks_like_digital_ocean?
67
+ digital_ocean Mash.new
68
+ hint = hint?('digital_ocean') || {}
69
+ hint.each {|k, v| digital_ocean[k] = v unless k == 'ip_addresses'}
70
+
71
+ # Extract actual ip addresses
72
+ # The networks sub-hash is structured similarly to how
73
+ # Digital Ocean's v2 API structures things:
74
+ # https://developers.digitalocean.com/#droplets
75
+ digital_ocean[:networks] = extract_droplet_ip_addresses
76
+ else
77
+ Ohai::Log.debug("No hints present for digital_ocean.")
78
+ false
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,32 @@
1
+ # Author:: Christopher M Luciano (<cmlucian@us.ibm.com>)
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ Ohai.plugin(:Elixir) do
17
+ provides "languages/elixir"
18
+
19
+ depends "languages"
20
+
21
+ collect_data do
22
+ output = nil
23
+
24
+ elixir = Mash.new
25
+ so = shell_out("elixir -v")
26
+ if so.exitstatus == 0
27
+ output = so.stdout.split
28
+ elixir[:version] = output[1]
29
+ languages[:elixir] = elixir if elixir[:version]
30
+ end
31
+ end
32
+ end
@@ -56,6 +56,7 @@ Ohai.plugin(:Linode) do
56
56
  linode Mash.new
57
57
  get_ip_address(:public_ip, :eth0)
58
58
  get_ip_address(:private_ip, "eth0:1")
59
+ hint?('linode').each{|k,v| linode[k] = v } if hint?('linode').kind_of?(Hash)
59
60
  end
60
61
  end
61
62
  end
@@ -35,6 +35,11 @@ Ohai.plugin(:BlockDevice) do
35
35
  File.open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
36
36
  end
37
37
  end
38
+ %w{rotational}.each do |check|
39
+ if File.exists?("/sys/block/#{dir}/queue/#{check}")
40
+ File.open("/sys/block/#{dir}/queue/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
41
+ end
42
+ end
38
43
  end
39
44
  block_device block
40
45
  end
@@ -32,7 +32,12 @@ Ohai.plugin(:CPU) do
32
32
  current_cpu = $1
33
33
  cpu_number += 1
34
34
  when /vendor_id\s+:\s(.+)/
35
- cpuinfo[current_cpu]["vendor_id"] = $1
35
+ vendor_id = $1
36
+ if vendor_id =~ (/IBM\/S390/)
37
+ cpuinfo["vendor_id"] = vendor_id
38
+ else
39
+ cpuinfo[current_cpu]["vendor_id"] = vendor_id
40
+ end
36
41
  when /cpu family\s+:\s(.+)/
37
42
  cpuinfo[current_cpu]["family"] = $1
38
43
  when /model\s+:\s(.+)/
@@ -54,6 +59,21 @@ Ohai.plugin(:CPU) do
54
59
  cpuinfo[current_cpu]["cache_size"] = $1
55
60
  when /flags\s+:\s(.+)/
56
61
  cpuinfo[current_cpu]["flags"] = $1.split(' ')
62
+ when /bogomips per cpu:\s(.+)/
63
+ cpuinfo["bogomips_per_cpu"] = $1
64
+ when /features\s+:\s(.+)/
65
+ cpuinfo["features"] = $1.split(' ')
66
+ when /processor\s(\d):\s(.+)/
67
+ current_cpu = $1
68
+ cpu_number += 1
69
+ cpuinfo[current_cpu] = Mash.new
70
+ current_cpu_info = $2.split(',')
71
+ for i in current_cpu_info
72
+ name_value = i.split('=')
73
+ name = name_value[0].strip
74
+ value = name_value[1].strip
75
+ cpuinfo[current_cpu][name] = value
76
+ end
57
77
  end
58
78
  end
59
79
 
@@ -62,7 +62,7 @@ Ohai.plugin(:Filesystem) do
62
62
  end
63
63
 
64
64
  # Grab filesystem inode data from df
65
- so = shell_out("df -i")
65
+ so = shell_out("df -iP")
66
66
  so.stdout.lines do |line|
67
67
  case line
68
68
  when /^Filesystem\s+Inodes/
@@ -33,6 +33,10 @@ Ohai.plugin(:Network) do
33
33
  encap
34
34
  end
35
35
 
36
+ def iproute2_binary_available?
37
+ ["/sbin/ip", "/usr/bin/ip"].any? { |path| File.exist?(path) }
38
+ end
39
+
36
40
  collect_data(:linux) do
37
41
  require 'ipaddr'
38
42
 
@@ -49,8 +53,7 @@ Ohai.plugin(:Network) do
49
53
  # The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
50
54
  IPROUTE_INT_REGEX = /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/ unless defined? IPROUTE_INT_REGEX
51
55
 
52
- if File.exist?("/sbin/ip")
53
-
56
+ if iproute2_binary_available?
54
57
  # families to get default routes from
55
58
  families = [{
56
59
  :name => "inet",
@@ -137,6 +140,7 @@ Ohai.plugin(:Network) do
137
140
  so.stdout.lines do |line|
138
141
  if line =~ IPROUTE_INT_REGEX
139
142
  tmp_int = $2
143
+ iface[tmp_int] = Mash.new unless iface[tmp_int]
140
144
  net_counters[tmp_int] = Mash.new unless net_counters[tmp_int]
141
145
  end
142
146
 
@@ -87,10 +87,12 @@ Ohai.plugin(:Platform) do
87
87
  platform "arch"
88
88
  # no way to determine platform_version in a rolling release distribution
89
89
  # kernel release will be used - ex. 2.6.32-ARCH
90
+ platform_version `uname -r`.strip
90
91
  elsif File.exists?('/etc/exherbo-release')
91
92
  platform "exherbo"
92
93
  # no way to determine platform_version in a rolling release distribution
93
94
  # kernel release will be used - ex. 3.13
95
+ platform_version `uname -r`.strip
94
96
  elsif lsb[:id] =~ /RedHat/i
95
97
  platform "redhat"
96
98
  platform_version lsb[:release]
@@ -27,6 +27,10 @@ Ohai.plugin(:Virtualization) do
27
27
  which('lxc-version')
28
28
  end
29
29
 
30
+ def docker_exists?
31
+ which('docker')
32
+ end
33
+
30
34
  collect_data(:linux) do
31
35
  virtualization Mash.new unless virtualization
32
36
  virtualization[:systems] = Mash.new unless virtualization[:systems]
@@ -129,6 +133,10 @@ Ohai.plugin(:Virtualization) do
129
133
  virtualization[:role] = "guest"
130
134
  virtualization[:systems][:vbox] = "guest"
131
135
  end
136
+ when /Product Name: OpenStack/
137
+ virtualization[:system] = "openstack"
138
+ virtualization[:role] = "guest"
139
+ virtualization[:systems][:openstack] = "guest"
132
140
  else
133
141
  nil
134
142
  end
@@ -170,9 +178,9 @@ Ohai.plugin(:Virtualization) do
170
178
  # Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
171
179
  if File.exists?("/proc/self/cgroup")
172
180
  if File.read("/proc/self/cgroup") =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$}
173
- virtualization[:system] = "lxc"
181
+ virtualization[:system] = $1
174
182
  virtualization[:role] = "guest"
175
- virtualization[:systems][:lxc] = "guest"
183
+ virtualization[:systems][$1.to_sym] = "guest"
176
184
  elsif lxc_version_exists? && File.read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
177
185
  # lxc-version shouldn't be installed by default
178
186
  # Even so, it is likely we are on an LXC capable host that is not being used as such
@@ -181,12 +189,15 @@ Ohai.plugin(:Virtualization) do
181
189
  virtualization[:system] = "lxc"
182
190
  virtualization[:role] = "host"
183
191
  end
184
-
185
192
  # In general, the 'systems' framework from OHAI-182 is less susceptible to conflicts
186
193
  # But, this could overwrite virtualization[:systems][:lxc] = "guest"
187
194
  # If so, we may need to look further for a differentiator (OHAI-573)
188
195
  virtualization[:systems][:lxc] = "host"
189
196
  end
197
+ elsif File.exists?("/.dockerenv") || File.exists?("/.dockerinit")
198
+ virtualization[:system] = "docker"
199
+ virtualization[:role] = "guest"
200
+ virtualization[:systems][:docker] = "guest"
190
201
  end
191
202
  end
192
203
  end