ohai 16.10.4 → 17.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/lib/ohai/mixin/alibaba_metadata.rb +86 -0
- data/lib/ohai/plugins/aix/virtualization.rb +4 -3
- data/lib/ohai/plugins/alibaba.rb +72 -0
- data/lib/ohai/plugins/c.rb +6 -8
- data/lib/ohai/plugins/chef.rb +11 -0
- data/lib/ohai/plugins/cloud.rb +20 -3
- data/lib/ohai/plugins/cpu.rb +245 -34
- data/lib/ohai/plugins/eucalyptus.rb +1 -1
- data/lib/ohai/plugins/filesystem.rb +4 -17
- data/lib/ohai/plugins/habitat.rb +73 -0
- data/lib/ohai/plugins/hostname.rb +22 -1
- data/lib/ohai/plugins/linux/network.rb +29 -4
- data/lib/ohai/plugins/linux/os_release.rb +38 -0
- data/lib/ohai/plugins/linux/platform.rb +22 -19
- data/lib/ohai/plugins/linux/virtualization.rb +40 -2
- data/lib/ohai/plugins/network.rb +1 -1
- data/lib/ohai/plugins/packages.rb +5 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +4 -8
- metadata +21 -17
@@ -29,7 +29,7 @@ Ohai.plugin(:Eucalyptus) do
|
|
29
29
|
provides "eucalyptus"
|
30
30
|
depends "network/interfaces"
|
31
31
|
|
32
|
-
MAC_MATCH = /^[dD]0:0[dD]:/.freeze
|
32
|
+
MAC_MATCH = /^[dD]0:0[dD]:/.freeze unless defined?(MAC_MATCH)
|
33
33
|
|
34
34
|
# returns the mac address from the collection of all address types
|
35
35
|
def get_mac_address(addresses)
|
@@ -98,14 +98,6 @@ Ohai.plugin(:Filesystem) do
|
|
98
98
|
view
|
99
99
|
end
|
100
100
|
|
101
|
-
def generate_deprecated_windows_view(fs)
|
102
|
-
view = generate_mountpoint_view(fs)
|
103
|
-
view.each do |mp, entry|
|
104
|
-
view[mp].delete("devices")
|
105
|
-
end
|
106
|
-
view
|
107
|
-
end
|
108
|
-
|
109
101
|
def parse_common_df(out)
|
110
102
|
fs = {}
|
111
103
|
out.each_line do |line|
|
@@ -466,9 +458,7 @@ Ohai.plugin(:Filesystem) do
|
|
466
458
|
fs_data["by_mountpoint"] = by_mountpoint
|
467
459
|
fs_data["by_pair"] = by_pair
|
468
460
|
|
469
|
-
# @todo in Chef 17 the filesystem2 part of this goes away
|
470
461
|
filesystem fs_data
|
471
|
-
filesystem2 fs_data
|
472
462
|
end
|
473
463
|
|
474
464
|
collect_data(:darwin) do
|
@@ -613,9 +603,7 @@ Ohai.plugin(:Filesystem) do
|
|
613
603
|
fs_data["by_mountpoint"] = by_mountpoint
|
614
604
|
fs_data["by_pair"] = by_pair
|
615
605
|
|
616
|
-
# @todo in Chef 17 the filesystem2 plugin goes away
|
617
606
|
filesystem fs_data
|
618
|
-
filesystem2 fs_data
|
619
607
|
end
|
620
608
|
|
621
609
|
collect_data(:aix) do
|
@@ -705,9 +693,7 @@ Ohai.plugin(:Filesystem) do
|
|
705
693
|
fs_data["by_mountpoint"] = by_mountpoint
|
706
694
|
fs_data["by_pair"] = by_pair
|
707
695
|
|
708
|
-
# @todo in Chef 17 the filesystem2 plugin goes away here
|
709
696
|
filesystem fs_data
|
710
|
-
filesystem2 fs_data
|
711
697
|
end
|
712
698
|
|
713
699
|
collect_data(:windows) do
|
@@ -726,9 +712,10 @@ Ohai.plugin(:Filesystem) do
|
|
726
712
|
fs_data["by_mountpoint"] = by_mountpoint
|
727
713
|
fs_data["by_pair"] = by_pair
|
728
714
|
|
729
|
-
#
|
730
|
-
#
|
731
|
-
|
715
|
+
# Chef 16 added 'filesystem2'
|
716
|
+
# In Chef 17 we made 'filesystem' and 'filesystem2' match (both new-style)
|
717
|
+
# In Chef 18 we will drop 'filesystem2'
|
718
|
+
filesystem fs_data
|
732
719
|
filesystem2 fs_data
|
733
720
|
end
|
734
721
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
#
|
19
|
+
Ohai.plugin(:Habitat) do
|
20
|
+
provides "habitat"
|
21
|
+
|
22
|
+
def habitat_binary
|
23
|
+
@habitat_binary ||= which("hab")
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_habitat_version
|
27
|
+
shell_out([habitat_binary, "-V"]).stdout.gsub(/hab\s*/, "").strip
|
28
|
+
rescue Ohai::Exceptions::Exec
|
29
|
+
logger.trace("Plugin Habitat: Unable to determine the installed version of Habitat, skipping collection.")
|
30
|
+
end
|
31
|
+
|
32
|
+
def fetch_habitat_packages
|
33
|
+
shell_out([habitat_binary, "pkg", "list", "--all"]).stdout.split.sort.select { |pkg| pkg.match?(%r{.*/.*/.*/.*}) }
|
34
|
+
rescue Ohai::Exceptions::Exec
|
35
|
+
logger.trace("Plugin Habitat: Unable to determine the installed Habitat packages, skipping collection.")
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_habitat_service_via_cli(status_stdout)
|
39
|
+
# package type desired state elapsed (s) pid group
|
40
|
+
# core/httpd/2.4.35/20190307151146 standalone up up 158169 1410 httpd.default
|
41
|
+
@services = []
|
42
|
+
status_stdout.each_line do |line|
|
43
|
+
fields = line.split(/\s+/)
|
44
|
+
next unless fields[0].match?(%r{.*/.*/.*/.*}) # ignore header line
|
45
|
+
|
46
|
+
service = {}
|
47
|
+
service[:identity] = fields[0]
|
48
|
+
service[:topology] = fields[1]
|
49
|
+
service[:state_desired] = fields[2]
|
50
|
+
service[:state_actual] = fields[2]
|
51
|
+
(@services).push(service)
|
52
|
+
end
|
53
|
+
@services
|
54
|
+
end
|
55
|
+
|
56
|
+
def fetch_habitat_services
|
57
|
+
services_shell_out = shell_out([habitat_binary, "svc", "status"]).stdout
|
58
|
+
load_habitat_service_via_cli(services_shell_out) if services_shell_out
|
59
|
+
rescue Ohai::Exceptions::Exec
|
60
|
+
logger.trace("Plugin Habitat: Unable to determine the installed Habitat services, skipping collection.")
|
61
|
+
end
|
62
|
+
|
63
|
+
collect_data(:default) do
|
64
|
+
if habitat_binary
|
65
|
+
habitat Mash.new
|
66
|
+
habitat["version"] = fetch_habitat_version
|
67
|
+
habitat["packages"] = fetch_habitat_packages
|
68
|
+
habitat["services"] = fetch_habitat_services
|
69
|
+
else
|
70
|
+
logger.trace("Plugin Habitat: Could not find hab binary. Skipping plugin.")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -48,7 +48,28 @@ Ohai.plugin(:Hostname) do
|
|
48
48
|
require "ipaddr" unless defined?(IPAddr)
|
49
49
|
|
50
50
|
hostname = from_cmd("hostname")
|
51
|
-
|
51
|
+
begin
|
52
|
+
addrinfo = Socket.getaddrinfo(hostname, nil).first
|
53
|
+
rescue SocketError
|
54
|
+
# In the event that we got an exception from Socket, it's possible
|
55
|
+
# that it will work if we restrict it to IPv4 only either because of
|
56
|
+
# IPv6 misconfiguration or other bugs.
|
57
|
+
#
|
58
|
+
# Specifically it's worth noting that on macOS, getaddrinfo() will choke
|
59
|
+
# if it gets back a link-local address (say if you have 'fe80::1 myhost'
|
60
|
+
# in /etc/hosts). This will raise:
|
61
|
+
# SocketError (getnameinfo: Non-recoverable failure in name resolution)
|
62
|
+
#
|
63
|
+
# But general misconfiguration could cause similar issues, so attempt to
|
64
|
+
# fall back to v4-only
|
65
|
+
begin
|
66
|
+
addrinfo = Socket.getaddrinfo(hostname, nil, :INET).first
|
67
|
+
rescue
|
68
|
+
# and if *that* fails, then try v6-only, in case we're in a v6-only
|
69
|
+
# environment with v4 config issues
|
70
|
+
addrinfo = Socket.getaddrinfo(hostname, nil, :INET6).first
|
71
|
+
end
|
72
|
+
end
|
52
73
|
iaddr = IPAddr.new(addrinfo[3])
|
53
74
|
Socket.gethostbyaddr(iaddr.hton)[0]
|
54
75
|
rescue
|
@@ -141,13 +141,13 @@ Ohai.plugin(:Network) do
|
|
141
141
|
|
142
142
|
# using a temporary var to hold routes and their interface name
|
143
143
|
def parse_routes(family, iface)
|
144
|
-
iface.
|
144
|
+
iface.filter_map do |i, iv|
|
145
145
|
next unless iv[:routes]
|
146
146
|
|
147
|
-
iv[:routes].
|
147
|
+
iv[:routes].filter_map do |r|
|
148
148
|
r.merge(dev: i) if r[:family] == family[:name]
|
149
|
-
end
|
150
|
-
end.
|
149
|
+
end
|
150
|
+
end.flatten
|
151
151
|
end
|
152
152
|
|
153
153
|
# determine layer 1 details for the interface using ethtool
|
@@ -273,6 +273,30 @@ Ohai.plugin(:Network) do
|
|
273
273
|
iface
|
274
274
|
end
|
275
275
|
|
276
|
+
# determine offload features for the interface using ethtool
|
277
|
+
def ethernet_offload_parameters(iface)
|
278
|
+
return iface unless ethtool_binary_path
|
279
|
+
|
280
|
+
iface.each_key do |tmp_int|
|
281
|
+
next unless iface[tmp_int][:encapsulation] == "Ethernet"
|
282
|
+
|
283
|
+
so = shell_out("#{ethtool_binary_path} -k #{tmp_int}")
|
284
|
+
Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{so.stdout}")
|
285
|
+
iface[tmp_int]["offload_params"] = {}
|
286
|
+
so.stdout.lines.each do |line|
|
287
|
+
next if line.start_with?("Features for")
|
288
|
+
next if line.strip.nil?
|
289
|
+
|
290
|
+
key, val = line.split(/:\s+/)
|
291
|
+
if val
|
292
|
+
offload_key = key.downcase.strip.tr(" ", "_").to_s
|
293
|
+
iface[tmp_int]["offload_params"][offload_key] = val.downcase.gsub(/\[.*\]/, "").strip.to_s
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
iface
|
298
|
+
end
|
299
|
+
|
276
300
|
# determine pause parameters for the interface using ethtool
|
277
301
|
def ethernet_pause_parameters(iface)
|
278
302
|
return iface unless ethtool_binary_path
|
@@ -793,6 +817,7 @@ Ohai.plugin(:Network) do
|
|
793
817
|
iface = ethernet_ring_parameters(iface)
|
794
818
|
iface = ethernet_channel_parameters(iface)
|
795
819
|
iface = ethernet_coalesce_parameters(iface)
|
820
|
+
iface = ethernet_offload_parameters(iface)
|
796
821
|
iface = ethernet_driver_info(iface)
|
797
822
|
iface = ethernet_pause_parameters(iface)
|
798
823
|
counters[:network][:interfaces] = net_counters
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Lance Albertson (lance@osuosl.org>)
|
4
|
+
# Copyright:: Copyright (c) 2021 Oregon State University
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:OsRelease) do
|
21
|
+
provides "os_release"
|
22
|
+
|
23
|
+
collect_data(:linux) do
|
24
|
+
os_release Mash.new unless os_release
|
25
|
+
|
26
|
+
# https://www.freedesktop.org/software/systemd/man/os-release.html
|
27
|
+
if file_exist?("/etc/os-release")
|
28
|
+
file_read("/etc/os-release").each_line do |line|
|
29
|
+
key, value = line.split("=")
|
30
|
+
if key == "ID_LIKE"
|
31
|
+
os_release[key.downcase] = value.chomp.gsub(/\A"|"\Z/, "").split(" ") if value
|
32
|
+
else
|
33
|
+
os_release[key.downcase] = value.chomp.gsub(/\A"|"\Z/, "") if value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -54,7 +54,7 @@ Ohai.plugin(:Platform) do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
#
|
57
|
-
# Cached /etc/os-release info Hash.
|
57
|
+
# Cached /etc/os-release info Hash. Also has logic for Cisco Nexus
|
58
58
|
# switches that pulls the chained CISCO_RELEASE_INFO file into the Hash (other
|
59
59
|
# distros can also reuse this method safely).
|
60
60
|
#
|
@@ -112,16 +112,17 @@ Ohai.plugin(:Platform) do
|
|
112
112
|
# ohai uses. If you're adding a new platform here and you want to change the name
|
113
113
|
# you'll want to add it here and then add a spec for the platform_id_remap method
|
114
114
|
{
|
115
|
-
"
|
115
|
+
"alinux" => "alibabalinux",
|
116
116
|
"amzn" => "amazon",
|
117
|
+
"archarm" => "arch",
|
118
|
+
"cumulus-linux" => "cumulus",
|
117
119
|
"ol" => "oracle",
|
118
|
-
"sles" => "suse",
|
119
|
-
"sles_sap" => "suse",
|
120
120
|
"opensuse-leap" => "opensuseleap",
|
121
|
+
"rhel" => "redhat",
|
122
|
+
"sles_sap" => "suse",
|
123
|
+
"sles" => "suse",
|
121
124
|
"xenenterprise" => "xenserver",
|
122
|
-
|
123
|
-
"archarm" => "arch",
|
124
|
-
}[id] || id
|
125
|
+
}[id.downcase] || id.downcase
|
125
126
|
end
|
126
127
|
|
127
128
|
#
|
@@ -133,22 +134,24 @@ Ohai.plugin(:Platform) do
|
|
133
134
|
#
|
134
135
|
def platform_family_from_platform(plat)
|
135
136
|
case plat
|
136
|
-
when /
|
137
|
+
when /ubuntu/, /debian/, /linuxmint/, /raspbian/, /cumulus/, /kali/, /pop/
|
137
138
|
# apt-get+dpkg almost certainly goes here
|
138
139
|
"debian"
|
139
|
-
when /
|
140
|
+
when /centos/, /redhat/, /oracle/, /almalinux/, /scientific/, /enterpriseenterprise/, /xenserver/, /xcp-ng/, /cloudlinux/, /alibabalinux/, /sangoma/, /clearos/, /parallels/, /ibm_powerkvm/, /nexus_centos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
140
141
|
# NOTE: "rhel" should be reserved exclusively for recompiled rhel versions that are nearly perfectly compatible down to the platform_version.
|
141
142
|
# The operating systems that are "rhel" should all be as compatible as rhel7 = centos7 = oracle7 = scientific7 (98%-ish core RPM version compatibility
|
142
143
|
# and the version numbers MUST track the upstream). The appropriate EPEL version repo should work nearly perfectly. Some variation like the
|
143
|
-
# oracle kernel version differences and tuning and extra packages are clearly acceptable.
|
144
|
-
# should not be in this list.
|
144
|
+
# oracle kernel version differences and tuning and extra packages are clearly acceptable. Almost certainly some distros above (xenserver?)
|
145
|
+
# should not be in this list. Please use fedora, below, instead. Also note that this is the only platform_family with this strict of a rule,
|
145
146
|
# see the example of the debian platform family for how the rest of the platform_family designations should be used.
|
147
|
+
#
|
148
|
+
# TODO: when XCP-NG 7.4 support ends we can remove the xcp-ng match. 7.5+ reports as xenenterprise which we remap to xenserver
|
146
149
|
"rhel"
|
147
150
|
when /amazon/
|
148
151
|
"amazon"
|
149
|
-
when /suse/, /sles/, /
|
152
|
+
when /suse/, /sles/, /opensuseleap/, /opensuse/, /sled/
|
150
153
|
"suse"
|
151
|
-
when /fedora/, /
|
154
|
+
when /fedora/, /arista_eos/
|
152
155
|
# In the broadest sense: RPM-based, fedora-derived distributions which are not strictly re-compiled RHEL (if it uses RPMs, and smells more like redhat and less like
|
153
156
|
# SuSE it probably goes here).
|
154
157
|
"fedora"
|
@@ -156,9 +159,7 @@ Ohai.plugin(:Platform) do
|
|
156
159
|
"wrlinux"
|
157
160
|
when /gentoo/
|
158
161
|
"gentoo"
|
159
|
-
when /
|
160
|
-
"slackware"
|
161
|
-
when /arch/, /manjaro/, /antergos/
|
162
|
+
when /arch/, /manjaro/
|
162
163
|
"arch"
|
163
164
|
when /exherbo/
|
164
165
|
"exherbo"
|
@@ -168,6 +169,8 @@ Ohai.plugin(:Platform) do
|
|
168
169
|
"clearlinux"
|
169
170
|
when /mangeia/
|
170
171
|
"mandriva"
|
172
|
+
when /slackware/
|
173
|
+
"slackware"
|
171
174
|
end
|
172
175
|
end
|
173
176
|
|
@@ -270,9 +273,6 @@ Ohai.plugin(:Platform) do
|
|
270
273
|
elsif /XenServer/i.match?(lsb[:id])
|
271
274
|
platform "xenserver"
|
272
275
|
platform_version lsb[:release]
|
273
|
-
elsif /XCP/i.match?(lsb[:id])
|
274
|
-
platform "xcp"
|
275
|
-
platform_version lsb[:release]
|
276
276
|
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties
|
277
277
|
platform lsb[:id].downcase
|
278
278
|
platform_version lsb[:release]
|
@@ -287,6 +287,9 @@ Ohai.plugin(:Platform) do
|
|
287
287
|
# centos only includes the major version in os-release for some reason
|
288
288
|
if os_release_info["ID"] == "centos"
|
289
289
|
get_redhatish_version(file_read("/etc/redhat-release").chomp)
|
290
|
+
# debian testing and unstable don't have VERSION_ID set
|
291
|
+
elsif os_release_info["ID"] == "debian"
|
292
|
+
os_release_info["VERSION_ID"] || file_read("/etc/debian_version").chomp
|
290
293
|
else
|
291
294
|
os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
|
292
295
|
end
|
@@ -20,6 +20,7 @@
|
|
20
20
|
Ohai.plugin(:Virtualization) do
|
21
21
|
provides "virtualization"
|
22
22
|
depends "dmi"
|
23
|
+
depends "cpu"
|
23
24
|
require_relative "../../mixin/dmi_decode"
|
24
25
|
include Ohai::Mixin::DmiDecode
|
25
26
|
|
@@ -35,6 +36,10 @@ Ohai.plugin(:Virtualization) do
|
|
35
36
|
which("docker")
|
36
37
|
end
|
37
38
|
|
39
|
+
def podman_exists?
|
40
|
+
which("podman")
|
41
|
+
end
|
42
|
+
|
38
43
|
collect_data(:linux) do
|
39
44
|
virtualization Mash.new unless virtualization
|
40
45
|
virtualization[:systems] ||= Mash.new
|
@@ -46,6 +51,13 @@ Ohai.plugin(:Virtualization) do
|
|
46
51
|
virtualization[:systems][:docker] = "host"
|
47
52
|
end
|
48
53
|
|
54
|
+
# Podman hosts
|
55
|
+
if podman_exists?
|
56
|
+
virtualization[:system] = "podman"
|
57
|
+
virtualization[:role] = "host"
|
58
|
+
virtualization[:systems][:podman] = "host"
|
59
|
+
end
|
60
|
+
|
49
61
|
# Xen Notes:
|
50
62
|
# - /proc/xen is an empty dir for EL6 + Linode Guests + Paravirt EC2 instances
|
51
63
|
# - cpuid of guests, if we could get it, would also be a clue
|
@@ -115,6 +127,14 @@ Ohai.plugin(:Virtualization) do
|
|
115
127
|
virtualization[:role] = "host"
|
116
128
|
virtualization[:systems][:kvm] = "host"
|
117
129
|
end
|
130
|
+
elsif get_attribute(:cpu, :hypervisor_vendor)
|
131
|
+
if get_attribute(:cpu, :hypervisor_vendor) == "KVM"
|
132
|
+
virtualization[:system] = "kvm"
|
133
|
+
if /(para|full)/.match?(get_attribute(:cpu, :virtualization_type))
|
134
|
+
virtualization[:role] = "guest"
|
135
|
+
virtualization[:systems][:kvm] = "guest"
|
136
|
+
end
|
137
|
+
end
|
118
138
|
end
|
119
139
|
|
120
140
|
# parse dmi to discover various virtualization guests
|
@@ -188,7 +208,7 @@ Ohai.plugin(:Virtualization) do
|
|
188
208
|
# <index #>:<subsystem>:/
|
189
209
|
#
|
190
210
|
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
191
|
-
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
211
|
+
# Kernel docs, https://web.archive.org/web/20100514070914/http://www.kernel.org/doc/Documentation/cgroups/
|
192
212
|
if file_exist?("/proc/self/cgroup")
|
193
213
|
cgroup_content = file_read("/proc/self/cgroup")
|
194
214
|
# These two REs catch many different examples. Here's a specific one
|
@@ -210,6 +230,20 @@ Ohai.plugin(:Virtualization) do
|
|
210
230
|
virtualization[:system] = "nspawn"
|
211
231
|
virtualization[:role] = "guest"
|
212
232
|
virtualization[:systems][:nspawn] = "guest"
|
233
|
+
elsif /container=podman/.match?(file_read("/proc/1/environ"))
|
234
|
+
logger.trace("Plugin Virtualization: /proc/1/environ indicates podman container. Detecting as podman guest")
|
235
|
+
virtualization[:system] = "podman"
|
236
|
+
virtualization[:role] = "guest"
|
237
|
+
virtualization[:systems][:podman] = "guest"
|
238
|
+
# Detect any containers that appear to be using docker such as those running on Github Actions virtual machines
|
239
|
+
# but aren't triggered by the cgroup regex above. It's pretty safe to assume if the cgroup contains containerd,
|
240
|
+
# it's likely using docker.
|
241
|
+
# https://rubular.com/r/qhSmV113cPmEBT
|
242
|
+
elsif %r{^\d+:[^:]*:/[^/]+/(containerd)-?.+$}.match?(cgroup_content)
|
243
|
+
logger.trace("Plugin Virtualization: /proc/self/cgroup indicates docker container. Detecting as docker guest")
|
244
|
+
virtualization[:system] = "docker"
|
245
|
+
virtualization[:role] = "guest"
|
246
|
+
virtualization[:systems][:docker] = "guest"
|
213
247
|
elsif lxc_version_exists? && file_read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
|
214
248
|
# lxc-version shouldn't be installed by default
|
215
249
|
# Even so, it is likely we are on an LXC capable host that is not being used as such
|
@@ -225,7 +259,11 @@ Ohai.plugin(:Virtualization) do
|
|
225
259
|
# If so, we may need to look further for a differentiator (OHAI-573)
|
226
260
|
virtualization[:systems][:lxc] = "host"
|
227
261
|
end
|
228
|
-
|
262
|
+
end
|
263
|
+
|
264
|
+
# regardless of what we found above, if we're a docker container inside
|
265
|
+
# of the above, lets report as a docker container
|
266
|
+
if file_exist?("/.dockerenv") || file_exist?("/.dockerinit")
|
229
267
|
logger.trace("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
|
230
268
|
virtualization[:system] = "docker"
|
231
269
|
virtualization[:role] = "guest"
|