ohai 16.5.4 → 16.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -8
- data/bin/ohai +1 -0
- data/lib/ohai.rb +1 -0
- data/lib/ohai/application.rb +40 -0
- data/lib/ohai/common/dmi.rb +8 -3
- data/lib/ohai/config.rb +1 -0
- data/lib/ohai/dsl.rb +1 -0
- data/lib/ohai/dsl/plugin.rb +9 -1
- data/lib/ohai/dsl/plugin/versionvii.rb +28 -17
- data/lib/ohai/exception.rb +1 -0
- data/lib/ohai/hints.rb +1 -0
- data/lib/ohai/log.rb +1 -0
- data/lib/ohai/mash.rb +1 -0
- data/lib/ohai/mixin/azure_metadata.rb +4 -3
- data/lib/ohai/mixin/chef_utils_wiring.rb +14 -1
- data/lib/ohai/mixin/command.rb +1 -0
- data/lib/ohai/mixin/constant_helper.rb +1 -0
- data/lib/ohai/mixin/dmi_decode.rb +1 -0
- data/lib/ohai/mixin/do_metadata.rb +3 -2
- data/lib/ohai/mixin/ec2_metadata.rb +10 -9
- data/lib/ohai/mixin/gce_metadata.rb +4 -3
- data/lib/ohai/mixin/http_helper.rb +1 -0
- data/lib/ohai/mixin/network_helper.rb +1 -0
- data/lib/ohai/mixin/os.rb +67 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
- data/lib/ohai/mixin/seconds_to_human.rb +1 -0
- data/lib/ohai/mixin/shell_out.rb +1 -0
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
- data/lib/ohai/mixin/string.rb +1 -0
- data/lib/ohai/mixin/train_helpers.rb +36 -0
- data/lib/ohai/mixin/which.rb +1 -0
- data/lib/ohai/plugin_config.rb +1 -0
- data/lib/ohai/plugins/aix/kernel.rb +7 -4
- data/lib/ohai/plugins/aix/memory.rb +4 -3
- data/lib/ohai/plugins/aix/network.rb +51 -58
- data/lib/ohai/plugins/aix/platform.rb +3 -2
- data/lib/ohai/plugins/aix/uptime.rb +3 -2
- data/lib/ohai/plugins/aix/virtualization.rb +6 -6
- data/lib/ohai/plugins/azure.rb +25 -4
- data/lib/ohai/plugins/bsd/virtualization.rb +3 -2
- data/lib/ohai/plugins/c.rb +4 -3
- data/lib/ohai/plugins/chef.rb +2 -1
- data/lib/ohai/plugins/cloud.rb +2 -1
- data/lib/ohai/plugins/command.rb +1 -0
- data/lib/ohai/plugins/cpu.rb +31 -32
- data/lib/ohai/plugins/darwin/hardware.rb +1 -0
- data/lib/ohai/plugins/darwin/memory.rb +2 -3
- data/lib/ohai/plugins/darwin/network.rb +8 -9
- data/lib/ohai/plugins/darwin/platform.rb +1 -0
- data/lib/ohai/plugins/darwin/virtualization.rb +2 -1
- data/lib/ohai/plugins/digital_ocean.rb +3 -1
- data/lib/ohai/plugins/dmi.rb +6 -5
- data/lib/ohai/plugins/docker.rb +2 -1
- data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
- data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
- data/lib/ohai/plugins/ec2.rb +14 -7
- data/lib/ohai/plugins/elixir.rb +1 -1
- data/lib/ohai/plugins/erlang.rb +1 -0
- data/lib/ohai/plugins/eucalyptus.rb +4 -1
- data/lib/ohai/plugins/filesystem.rb +4 -4
- data/lib/ohai/plugins/fips.rb +1 -0
- data/lib/ohai/plugins/freebsd/memory.rb +9 -8
- data/lib/ohai/plugins/freebsd/network.rb +1 -0
- data/lib/ohai/plugins/freebsd/platform.rb +3 -2
- data/lib/ohai/plugins/gce.rb +3 -2
- data/lib/ohai/plugins/go.rb +1 -1
- data/lib/ohai/plugins/groovy.rb +1 -1
- data/lib/ohai/plugins/grub2.rb +40 -0
- data/lib/ohai/plugins/haskell.rb +1 -0
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/init_package.rb +2 -1
- data/lib/ohai/plugins/java.rb +1 -0
- data/lib/ohai/plugins/kernel.rb +14 -11
- data/lib/ohai/plugins/keys.rb +1 -0
- data/lib/ohai/plugins/languages.rb +1 -0
- data/lib/ohai/plugins/libvirt.rb +4 -3
- data/lib/ohai/plugins/linode.rb +22 -14
- data/lib/ohai/plugins/linux/block_device.rb +9 -8
- data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
- data/lib/ohai/plugins/linux/interrupts.rb +4 -3
- data/lib/ohai/plugins/linux/ipc.rb +2 -1
- data/lib/ohai/plugins/linux/lsb.rb +7 -20
- data/lib/ohai/plugins/linux/lspci.rb +1 -1
- data/lib/ohai/plugins/linux/machineid.rb +5 -4
- data/lib/ohai/plugins/linux/mdadm.rb +3 -2
- data/lib/ohai/plugins/linux/memory.rb +38 -37
- data/lib/ohai/plugins/linux/network.rb +7 -6
- data/lib/ohai/plugins/linux/platform.rb +31 -30
- data/lib/ohai/plugins/linux/selinux.rb +1 -0
- data/lib/ohai/plugins/linux/sessions.rb +1 -0
- data/lib/ohai/plugins/linux/sysctl.rb +1 -0
- data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
- data/lib/ohai/plugins/linux/virtualization.rb +24 -23
- data/lib/ohai/plugins/lua.rb +1 -1
- data/lib/ohai/plugins/mono.rb +1 -1
- data/lib/ohai/plugins/netbsd/memory.rb +1 -0
- data/lib/ohai/plugins/netbsd/network.rb +1 -0
- data/lib/ohai/plugins/netbsd/platform.rb +3 -2
- data/lib/ohai/plugins/network.rb +2 -1
- data/lib/ohai/plugins/nodejs.rb +1 -1
- data/lib/ohai/plugins/ohai.rb +1 -0
- data/lib/ohai/plugins/ohai_time.rb +2 -1
- data/lib/ohai/plugins/openbsd/memory.rb +1 -0
- data/lib/ohai/plugins/openbsd/network.rb +1 -0
- data/lib/ohai/plugins/openbsd/platform.rb +3 -2
- data/lib/ohai/plugins/openstack.rb +1 -0
- data/lib/ohai/plugins/os.rb +6 -1
- data/lib/ohai/plugins/packages.rb +2 -1
- data/lib/ohai/plugins/passwd.rb +58 -1
- data/lib/ohai/plugins/perl.rb +1 -1
- data/lib/ohai/plugins/php.rb +1 -1
- data/lib/ohai/plugins/platform.rb +1 -0
- data/lib/ohai/plugins/powershell.rb +1 -1
- data/lib/ohai/plugins/ps.rb +1 -0
- data/lib/ohai/plugins/python.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +6 -5
- data/lib/ohai/plugins/root_group.rb +1 -0
- data/lib/ohai/plugins/ruby.rb +3 -2
- data/lib/ohai/plugins/rust.rb +1 -1
- data/lib/ohai/plugins/scala.rb +1 -0
- data/lib/ohai/plugins/scaleway.rb +3 -2
- data/lib/ohai/plugins/scsi.rb +1 -1
- data/lib/ohai/plugins/shard.rb +1 -1
- data/lib/ohai/plugins/shells.rb +3 -2
- data/lib/ohai/plugins/softlayer.rb +1 -0
- data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
- data/lib/ohai/plugins/solaris2/memory.rb +1 -0
- data/lib/ohai/plugins/solaris2/network.rb +2 -1
- data/lib/ohai/plugins/solaris2/platform.rb +8 -14
- data/lib/ohai/plugins/solaris2/virtualization.rb +4 -4
- data/lib/ohai/plugins/ssh_host_key.rb +13 -12
- data/lib/ohai/plugins/sysconf.rb +1 -0
- data/lib/ohai/plugins/timezone.rb +1 -0
- data/lib/ohai/plugins/train.rb +35 -0
- data/lib/ohai/plugins/uptime.rb +2 -1
- data/lib/ohai/plugins/virtualbox.rb +2 -1
- data/lib/ohai/plugins/vmware.rb +3 -3
- data/lib/ohai/plugins/windows/dmi.rb +1 -0
- data/lib/ohai/plugins/windows/drivers.rb +1 -0
- data/lib/ohai/plugins/windows/memory.rb +1 -0
- data/lib/ohai/plugins/windows/network.rb +2 -1
- data/lib/ohai/plugins/windows/platform.rb +1 -0
- data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
- data/lib/ohai/plugins/windows/virtualization.rb +1 -0
- data/lib/ohai/plugins/zpools.rb +5 -3
- data/lib/ohai/provides_map.rb +1 -0
- data/lib/ohai/runner.rb +7 -4
- data/lib/ohai/system.rb +33 -4
- data/lib/ohai/train_transport.rb +29 -0
- data/lib/ohai/util/file_helper.rb +1 -0
- data/lib/ohai/util/ip_helper.rb +2 -1
- data/lib/ohai/util/win32.rb +1 -0
- data/lib/ohai/version.rb +2 -1
- data/ohai.gemspec +3 -1
- metadata +21 -4
- data/lib/ohai/plugins/joyent.rb +0 -77
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -43,9 +44,9 @@ Ohai.plugin(:Platform) do
|
|
43
44
|
# @returns [Hash] the file parsed into a Hash or nil
|
44
45
|
#
|
45
46
|
def read_os_release_info(file)
|
46
|
-
return nil unless
|
47
|
+
return nil unless file_exist?(file)
|
47
48
|
|
48
|
-
|
49
|
+
file_read(file).split.inject({}) do |map, line|
|
49
50
|
key, value = line.split("=")
|
50
51
|
map[key] = value.gsub(/\A"|"\Z/, "") if value
|
51
52
|
map
|
@@ -64,7 +65,7 @@ Ohai.plugin(:Platform) do
|
|
64
65
|
begin
|
65
66
|
os_release_info = read_os_release_info("/etc/os-release")
|
66
67
|
cisco_release_info = os_release_info["CISCO_RELEASE_INFO"] if os_release_info
|
67
|
-
if cisco_release_info &&
|
68
|
+
if cisco_release_info && file_exist?(cisco_release_info)
|
68
69
|
os_release_info.merge!(read_os_release_info(cisco_release_info))
|
69
70
|
end
|
70
71
|
os_release_info
|
@@ -77,7 +78,7 @@ Ohai.plugin(:Platform) do
|
|
77
78
|
# @returns [Boolean] if we are Cisco according to /etc/os-release
|
78
79
|
#
|
79
80
|
def os_release_file_is_cisco?
|
80
|
-
|
81
|
+
file_exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
|
81
82
|
end
|
82
83
|
|
83
84
|
#
|
@@ -88,7 +89,7 @@ Ohai.plugin(:Platform) do
|
|
88
89
|
# @returns [String] bigip Linux version from /etc/f5-release
|
89
90
|
#
|
90
91
|
def bigip_version
|
91
|
-
release_contents =
|
92
|
+
release_contents = file_read("/etc/f5-release")
|
92
93
|
release_contents.match(/BIG-IP release (\S*)/)[1] # http://rubular.com/r/O8nlrBVqSb
|
93
94
|
rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
|
94
95
|
logger.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version")
|
@@ -132,7 +133,7 @@ Ohai.plugin(:Platform) do
|
|
132
133
|
#
|
133
134
|
def platform_family_from_platform(plat)
|
134
135
|
case plat
|
135
|
-
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/
|
136
|
+
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/, /kali/, /pop/
|
136
137
|
# apt-get+dpkg almost certainly goes here
|
137
138
|
"debian"
|
138
139
|
when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /xcp/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/, /clearos/, /bigip/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
|
@@ -178,18 +179,18 @@ Ohai.plugin(:Platform) do
|
|
178
179
|
# @deprecated
|
179
180
|
def legacy_platform_detection
|
180
181
|
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
|
181
|
-
if
|
182
|
-
contents =
|
182
|
+
if file_exist?("/etc/oracle-release")
|
183
|
+
contents = file_read("/etc/oracle-release").chomp
|
183
184
|
platform "oracle"
|
184
185
|
platform_version get_redhatish_version(contents)
|
185
|
-
elsif
|
186
|
-
contents =
|
186
|
+
elsif file_exist?("/etc/enterprise-release")
|
187
|
+
contents = file_read("/etc/enterprise-release").chomp
|
187
188
|
platform "oracle"
|
188
189
|
platform_version get_redhatish_version(contents)
|
189
|
-
elsif
|
190
|
+
elsif file_exist?("/etc/f5-release")
|
190
191
|
platform "bigip"
|
191
192
|
platform_version bigip_version
|
192
|
-
elsif
|
193
|
+
elsif file_exist?("/etc/debian_version")
|
193
194
|
# Ubuntu and Debian both have /etc/debian_version
|
194
195
|
# Ubuntu should always have a working lsb, debian does not by default
|
195
196
|
if /Ubuntu/i.match?(lsb[:id])
|
@@ -197,25 +198,25 @@ Ohai.plugin(:Platform) do
|
|
197
198
|
platform_version lsb[:release]
|
198
199
|
else
|
199
200
|
platform "debian"
|
200
|
-
platform_version
|
201
|
+
platform_version file_read("/etc/debian_version").chomp
|
201
202
|
end
|
202
|
-
elsif
|
203
|
-
contents =
|
203
|
+
elsif file_exist?("/etc/parallels-release")
|
204
|
+
contents = file_read("/etc/parallels-release").chomp
|
204
205
|
platform get_redhatish_platform(contents)
|
205
206
|
platform_version contents.match(/(\d\.\d\.\d)/)[0]
|
206
|
-
elsif
|
207
|
+
elsif file_exist?("/etc/Eos-release")
|
207
208
|
platform "arista_eos"
|
208
|
-
platform_version
|
209
|
-
elsif
|
210
|
-
contents =
|
209
|
+
platform_version file_read("/etc/Eos-release").strip.split[-1]
|
210
|
+
elsif file_exist?("/etc/redhat-release")
|
211
|
+
contents = file_read("/etc/redhat-release").chomp
|
211
212
|
platform get_redhatish_platform(contents)
|
212
213
|
platform_version get_redhatish_version(contents)
|
213
|
-
elsif
|
214
|
-
contents =
|
214
|
+
elsif file_exist?("/etc/system-release")
|
215
|
+
contents = file_read("/etc/system-release").chomp
|
215
216
|
platform get_redhatish_platform(contents)
|
216
217
|
platform_version get_redhatish_version(contents)
|
217
|
-
elsif
|
218
|
-
suse_release =
|
218
|
+
elsif file_exist?("/etc/SuSE-release")
|
219
|
+
suse_release = file_read("/etc/SuSE-release")
|
219
220
|
suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
|
220
221
|
suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
|
221
222
|
platform_version suse_version
|
@@ -243,16 +244,16 @@ Ohai.plugin(:Platform) do
|
|
243
244
|
end
|
244
245
|
|
245
246
|
platform_version os_release_info["VERSION"]
|
246
|
-
elsif
|
247
|
+
elsif file_exist?("/etc/slackware-version")
|
247
248
|
platform "slackware"
|
248
|
-
platform_version
|
249
|
-
elsif
|
249
|
+
platform_version file_read("/etc/slackware-version").scan(/(\d+|\.+)/).join
|
250
|
+
elsif file_exist?("/etc/exherbo-release")
|
250
251
|
platform "exherbo"
|
251
252
|
# no way to determine platform_version in a rolling release distribution
|
252
253
|
# kernel release will be used - ex. 3.13
|
253
254
|
platform_version shell_out("/bin/uname -r").stdout.strip
|
254
|
-
elsif
|
255
|
-
contents =
|
255
|
+
elsif file_exist?("/usr/lib/os-release")
|
256
|
+
contents = file_read("/usr/lib/os-release")
|
256
257
|
if /clear-linux-os/.match?(contents) # Clear Linux https://clearlinux.org/
|
257
258
|
platform "clearlinux"
|
258
259
|
platform_version contents[/VERSION_ID=(\d+)/, 1]
|
@@ -285,14 +286,14 @@ Ohai.plugin(:Platform) do
|
|
285
286
|
def determine_os_version
|
286
287
|
# centos only includes the major version in os-release for some reason
|
287
288
|
if os_release_info["ID"] == "centos"
|
288
|
-
get_redhatish_version(
|
289
|
+
get_redhatish_version(file_read("/etc/redhat-release").chomp)
|
289
290
|
else
|
290
291
|
os_release_info["VERSION_ID"] || shell_out("/bin/uname -r").stdout.strip
|
291
292
|
end
|
292
293
|
end
|
293
294
|
|
294
295
|
collect_data(:linux) do
|
295
|
-
if
|
296
|
+
if file_exist?("/etc/os-release")
|
296
297
|
logger.trace("Plugin platform: Using /etc/os-release for platform detection")
|
297
298
|
|
298
299
|
# fixup os-release names to ohai platform names
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Thom May (<thom@clearairturbulence.org>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -51,15 +52,15 @@ Ohai.plugin(:Virtualization) do
|
|
51
52
|
# - may be able to determine if under paravirt from /dev/xen/evtchn (See OHAI-253)
|
52
53
|
# - Additional edge cases likely should not change the above assumptions
|
53
54
|
# but rather be additive - btm
|
54
|
-
if
|
55
|
+
if file_exist?("/proc/xen")
|
55
56
|
virtualization[:system] = "xen"
|
56
57
|
# Assume guest
|
57
58
|
virtualization[:role] = "guest"
|
58
59
|
virtualization[:systems][:xen] = "guest"
|
59
60
|
|
60
61
|
# This file should exist on most Xen systems, normally empty for guests
|
61
|
-
if
|
62
|
-
if /control_d/i.match?(
|
62
|
+
if file_exist?("/proc/xen/capabilities")
|
63
|
+
if /control_d/i.match?(file_read("/proc/xen/capabilities"))
|
63
64
|
logger.trace("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
|
64
65
|
virtualization[:role] = "host"
|
65
66
|
virtualization[:systems][:xen] = "host"
|
@@ -68,8 +69,8 @@ Ohai.plugin(:Virtualization) do
|
|
68
69
|
end
|
69
70
|
|
70
71
|
# Detect Virtualbox from kernel module
|
71
|
-
if
|
72
|
-
modules =
|
72
|
+
if file_exist?("/proc/modules")
|
73
|
+
modules = file_read("/proc/modules")
|
73
74
|
if /^vboxdrv/.match?(modules)
|
74
75
|
logger.trace("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
|
75
76
|
virtualization[:system] = "vbox"
|
@@ -92,8 +93,8 @@ Ohai.plugin(:Virtualization) do
|
|
92
93
|
end
|
93
94
|
|
94
95
|
# Detect paravirt KVM/QEMU from cpuinfo, report as KVM
|
95
|
-
if
|
96
|
-
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(
|
96
|
+
if file_exist?("/proc/cpuinfo")
|
97
|
+
if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(file_read("/proc/cpuinfo"))
|
97
98
|
logger.trace("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
|
98
99
|
virtualization[:system] = "kvm"
|
99
100
|
virtualization[:role] = "guest"
|
@@ -103,9 +104,9 @@ Ohai.plugin(:Virtualization) do
|
|
103
104
|
|
104
105
|
# Detect KVM systems via /sys
|
105
106
|
# guests will have the hypervisor cpu feature that hosts don't have
|
106
|
-
if
|
107
|
+
if file_exist?("/sys/devices/virtual/misc/kvm")
|
107
108
|
virtualization[:system] = "kvm"
|
108
|
-
if /hypervisor/.match?(
|
109
|
+
if /hypervisor/.match?(file_read("/proc/cpuinfo"))
|
109
110
|
logger.trace("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
|
110
111
|
virtualization[:role] = "guest"
|
111
112
|
virtualization[:systems][:kvm] = "guest"
|
@@ -129,12 +130,12 @@ Ohai.plugin(:Virtualization) do
|
|
129
130
|
|
130
131
|
# Detect OpenVZ / Virtuozzo.
|
131
132
|
# http://wiki.openvz.org/BC_proc_entries
|
132
|
-
if
|
133
|
+
if file_exist?("/proc/bc/0")
|
133
134
|
logger.trace("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
|
134
135
|
virtualization[:system] = "openvz"
|
135
136
|
virtualization[:role] = "host"
|
136
137
|
virtualization[:systems][:openvz] = "host"
|
137
|
-
elsif
|
138
|
+
elsif file_exist?("/proc/vz")
|
138
139
|
logger.trace("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
|
139
140
|
virtualization[:system] = "openvz"
|
140
141
|
virtualization[:role] = "guest"
|
@@ -142,9 +143,9 @@ Ohai.plugin(:Virtualization) do
|
|
142
143
|
end
|
143
144
|
|
144
145
|
# Detect Hyper-V guest and the hostname of the host
|
145
|
-
if
|
146
|
+
if file_exist?("/var/lib/hyperv/.kvp_pool_3")
|
146
147
|
logger.trace("Plugin Virtualization: /var/lib/hyperv/.kvp_pool_3 contains string indicating Hyper-V guest")
|
147
|
-
data =
|
148
|
+
data = file_read("/var/lib/hyperv/.kvp_pool_3")
|
148
149
|
hyperv_host = data[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join.downcase
|
149
150
|
virtualization[:system] = "hyperv"
|
150
151
|
virtualization[:role] = "guest"
|
@@ -153,8 +154,8 @@ Ohai.plugin(:Virtualization) do
|
|
153
154
|
end
|
154
155
|
|
155
156
|
# Detect Linux-VServer
|
156
|
-
if
|
157
|
-
proc_self_status =
|
157
|
+
if file_exist?("/proc/self/status")
|
158
|
+
proc_self_status = file_read("/proc/self/status")
|
158
159
|
vxid = proc_self_status.match(/^(s_context|VxID):\s*(\d+)$/)
|
159
160
|
if vxid && vxid[2]
|
160
161
|
virtualization[:system] = "linux-vserver"
|
@@ -188,8 +189,8 @@ Ohai.plugin(:Virtualization) do
|
|
188
189
|
#
|
189
190
|
# Full notes, https://tickets.opscode.com/browse/OHAI-551
|
190
191
|
# Kernel docs, https://www.kernel.org/doc/Documentation/cgroups
|
191
|
-
if
|
192
|
-
cgroup_content =
|
192
|
+
if file_exist?("/proc/self/cgroup")
|
193
|
+
cgroup_content = file_read("/proc/self/cgroup")
|
193
194
|
# These two REs catch many different examples. Here's a specific one
|
194
195
|
# from when it is docker and there is no subsystem name.
|
195
196
|
# https://rubular.com/r/dV13hiU9KxmiWB
|
@@ -199,17 +200,17 @@ Ohai.plugin(:Virtualization) do
|
|
199
200
|
virtualization[:system] = $1
|
200
201
|
virtualization[:role] = "guest"
|
201
202
|
virtualization[:systems][$1.to_sym] = "guest"
|
202
|
-
elsif /container=lxc/.match?(
|
203
|
+
elsif /container=lxc/.match?(file_read("/proc/1/environ"))
|
203
204
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates lxc container. Detecting as lxc guest")
|
204
205
|
virtualization[:system] = "lxc"
|
205
206
|
virtualization[:role] = "guest"
|
206
207
|
virtualization[:systems][:lxc] = "guest"
|
207
|
-
elsif /container=systemd-nspawn/.match?(
|
208
|
+
elsif /container=systemd-nspawn/.match?(file_read("/proc/1/environ"))
|
208
209
|
logger.trace("Plugin Virtualization: /proc/1/environ indicates nspawn container. Detecting as nspawn guest")
|
209
210
|
virtualization[:system] = "nspawn"
|
210
211
|
virtualization[:role] = "guest"
|
211
212
|
virtualization[:systems][:nspawn] = "guest"
|
212
|
-
elsif lxc_version_exists? &&
|
213
|
+
elsif lxc_version_exists? && file_read("/proc/self/cgroup") =~ %r{\d:[^:]+:/$}
|
213
214
|
# lxc-version shouldn't be installed by default
|
214
215
|
# Even so, it is likely we are on an LXC capable host that is not being used as such
|
215
216
|
# So we're cautious here to not overwrite other existing values (OHAI-573)
|
@@ -224,7 +225,7 @@ Ohai.plugin(:Virtualization) do
|
|
224
225
|
# If so, we may need to look further for a differentiator (OHAI-573)
|
225
226
|
virtualization[:systems][:lxc] = "host"
|
226
227
|
end
|
227
|
-
elsif
|
228
|
+
elsif file_exist?("/.dockerenv") || file_exist?("/.dockerinit")
|
228
229
|
logger.trace("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
|
229
230
|
virtualization[:system] = "docker"
|
230
231
|
virtualization[:role] = "guest"
|
@@ -233,7 +234,7 @@ Ohai.plugin(:Virtualization) do
|
|
233
234
|
|
234
235
|
# Detect LXD
|
235
236
|
# See https://github.com/lxc/lxd/blob/master/doc/dev-lxd.md
|
236
|
-
if
|
237
|
+
if file_exist?("/dev/lxd/sock")
|
237
238
|
logger.trace("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
|
238
239
|
virtualization[:system] = "lxd"
|
239
240
|
virtualization[:role] = "guest"
|
@@ -248,7 +249,7 @@ Ohai.plugin(:Virtualization) do
|
|
248
249
|
# Snap based installations utilize '/var/snap/lxd/common/lxd/'
|
249
250
|
# - includes all future releases starting with 2.21, and will be the only source of 3.1+ feature releases post-bionic
|
250
251
|
["/var/lib/lxd/devlxd", "/var/snap/lxd/common/lxd/devlxd"].each do |devlxd|
|
251
|
-
if
|
252
|
+
if file_exist?(devlxd)
|
252
253
|
logger.trace("Plugin Virtualization: #{devlxd} exists. Detecting as lxd host")
|
253
254
|
virtualization[:system] = "lxd"
|
254
255
|
virtualization[:role] = "host"
|
data/lib/ohai/plugins/lua.rb
CHANGED
data/lib/ohai/plugins/mono.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
4
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
|
|
20
21
|
provides "platform", "platform_version", "platform_family"
|
21
22
|
|
22
23
|
collect_data(:netbsd) do
|
23
|
-
platform shell_out("uname -s").stdout.
|
24
|
-
platform_version shell_out("uname -r").stdout.
|
24
|
+
platform shell_out("uname -s").stdout.strip.downcase
|
25
|
+
platform_version shell_out("uname -r").stdout.strip
|
25
26
|
platform_family "netbsd"
|
26
27
|
end
|
27
28
|
end
|
data/lib/ohai/plugins/network.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -38,7 +39,7 @@ Ohai.plugin(:NetworkAddresses) do
|
|
38
39
|
next if iface_v.nil? || !iface_v.key?("addresses")
|
39
40
|
|
40
41
|
iface_v["addresses"].each do |addr, addr_v|
|
41
|
-
next if addr_v.nil? || (
|
42
|
+
next if addr_v.nil? || (!addr_v.key? "family") || addr_v["family"] != family
|
42
43
|
|
43
44
|
ipaddresses << {
|
44
45
|
ipaddress: addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
|
data/lib/ohai/plugins/nodejs.rb
CHANGED
data/lib/ohai/plugins/ohai.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -19,7 +20,7 @@
|
|
19
20
|
Ohai.plugin(:OhaiTime) do
|
20
21
|
provides "ohai_time"
|
21
22
|
|
22
|
-
collect_data do
|
23
|
+
collect_data(:default, :target) do
|
23
24
|
ohai_time Time.now.to_f
|
24
25
|
end
|
25
26
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
4
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
@@ -20,8 +21,8 @@ Ohai.plugin(:Platform) do
|
|
20
21
|
provides "platform", "platform_version", "platform_family"
|
21
22
|
|
22
23
|
collect_data(:openbsd) do
|
23
|
-
platform shell_out("uname -s").stdout.
|
24
|
-
platform_version shell_out("uname -r").stdout.
|
24
|
+
platform shell_out("uname -s").stdout.strip.downcase
|
25
|
+
platform_version shell_out("uname -r").stdout.strip
|
25
26
|
platform_family "openbsd"
|
26
27
|
end
|
27
28
|
end
|