ohai 15.8.0 → 16.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -5
- data/lib/ohai/common/dmi.rb +13 -5
- data/lib/ohai/mash.rb +21 -201
- data/lib/ohai/mixin/azure_metadata.rb +70 -14
- data/lib/ohai/mixin/ec2_metadata.rb +1 -1
- data/lib/ohai/mixin/gce_metadata.rb +2 -2
- data/lib/ohai/plugins/c.rb +2 -2
- data/lib/ohai/plugins/cpu.rb +1 -1
- data/lib/ohai/plugins/darwin/hardware.rb +2 -2
- data/lib/ohai/plugins/darwin/platform.rb +3 -6
- data/lib/ohai/plugins/docker.rb +1 -1
- data/lib/ohai/plugins/ec2.rb +1 -1
- data/lib/ohai/plugins/eucalyptus.rb +2 -2
- data/lib/ohai/plugins/filesystem.rb +9 -43
- data/lib/ohai/plugins/{linux/fips.rb → fips.rb} +1 -1
- data/lib/ohai/plugins/gce.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +8 -7
- data/lib/ohai/plugins/linux/interrupts.rb +83 -0
- data/lib/ohai/plugins/linux/ipc.rb +51 -0
- data/lib/ohai/plugins/linux/network.rb +90 -0
- data/lib/ohai/plugins/linux/selinux.rb +68 -0
- data/lib/ohai/plugins/linux/virtualization.rb +2 -2
- data/lib/ohai/plugins/packages.rb +1 -1
- data/lib/ohai/plugins/rackspace.rb +1 -1
- data/lib/ohai/plugins/shard.rb +11 -1
- data/lib/ohai/plugins/virtualbox.rb +2 -2
- data/lib/ohai/plugins/windows/dmi.rb +94 -0
- data/lib/ohai/plugins/windows/system_enclosure.rb +3 -5
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +2 -1
- metadata +29 -6
- data/lib/ohai/plugins/windows/fips.rb +0 -38
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Davide Cavalca <dcavalca@fb.com>
|
3
|
+
# Copyright:: Copyright (c) 2020 Facebook
|
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(:Selinux) do
|
20
|
+
provides "selinux/status", "selinux/policy_booleans", "selinux/process_contexts", "selinux/file_contexts"
|
21
|
+
optional true
|
22
|
+
|
23
|
+
collect_data(:linux) do
|
24
|
+
sestatus_path = which("sestatus")
|
25
|
+
if sestatus_path
|
26
|
+
sestatus = shell_out("#{sestatus_path} -v -b")
|
27
|
+
|
28
|
+
selinux Mash.new unless selinux
|
29
|
+
selinux[:status] ||= Mash.new
|
30
|
+
selinux[:policy_booleans] ||= Mash.new
|
31
|
+
selinux[:process_contexts] ||= Mash.new
|
32
|
+
selinux[:file_contexts] ||= Mash.new
|
33
|
+
section = nil
|
34
|
+
|
35
|
+
sestatus.stdout.split("\n").each do |line|
|
36
|
+
line.chomp!
|
37
|
+
|
38
|
+
case line
|
39
|
+
when "Policy booleans:"
|
40
|
+
section = :policy_booleans
|
41
|
+
next
|
42
|
+
when "Process contexts:"
|
43
|
+
section = :process_contexts
|
44
|
+
next
|
45
|
+
when "File contexts:"
|
46
|
+
section = :file_contexts
|
47
|
+
next
|
48
|
+
else
|
49
|
+
if section.nil?
|
50
|
+
section = :status
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
key, val = line.split(/:?\s\s+/, 2)
|
55
|
+
next if key.nil?
|
56
|
+
|
57
|
+
unless key.start_with?("/")
|
58
|
+
key.downcase!
|
59
|
+
key.tr!(" ", "_")
|
60
|
+
end
|
61
|
+
|
62
|
+
selinux[section][key] = val
|
63
|
+
end
|
64
|
+
else
|
65
|
+
logger.debug("Plugin Selinux: Could not find sestatus. Skipping plugin.")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -118,8 +118,8 @@ Ohai.plugin(:Virtualization) do
|
|
118
118
|
|
119
119
|
# parse dmi to discover various virtualization guests
|
120
120
|
# we do this *after* the kvm detection so that OpenStack isn't detected as KVM
|
121
|
-
logger.trace("Looking up DMI data manufacturer: '#{get_attribute(:dmi, :system, :manufacturer)}'
|
122
|
-
guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :
|
121
|
+
logger.trace("Looking up DMI data manufacturer: '#{get_attribute(:dmi, :system, :manufacturer)}' product_name: '#{get_attribute(:dmi, :system, :product_name)}' version: '#{get_attribute(:dmi, :system, :version)}'")
|
122
|
+
guest = guest_from_dmi_data(get_attribute(:dmi, :system, :manufacturer), get_attribute(:dmi, :system, :product_name), get_attribute(:dmi, :system, :version))
|
123
123
|
if guest
|
124
124
|
logger.trace("Plugin Virtualization: DMI data indicates #{guest} guest")
|
125
125
|
virtualization[:system] = guest
|
@@ -191,7 +191,7 @@ Ohai.plugin(:Packages) do
|
|
191
191
|
chunked_lines = so.stdout.lines.map(&:strip).chunk do |line|
|
192
192
|
!line.empty? || nil
|
193
193
|
end
|
194
|
-
chunked_lines.each do |_, lines| # rubocop: disable
|
194
|
+
chunked_lines.each do |_, lines| # rubocop: disable Style/HashEachMethods
|
195
195
|
package = {}
|
196
196
|
lines.each do |line|
|
197
197
|
key, value = line.split(":", 2)
|
data/lib/ohai/plugins/shard.rb
CHANGED
@@ -22,10 +22,12 @@ Ohai.plugin(:ShardSeed) do
|
|
22
22
|
|
23
23
|
def get_dmi_property(dmi, thing)
|
24
24
|
%w{system base_board chassis}.each do |section|
|
25
|
-
|
25
|
+
if dmi[section] && dmi[section][thing] && !dmi[section][thing].strip.empty?
|
26
26
|
return dmi[section][thing]
|
27
27
|
end
|
28
28
|
end
|
29
|
+
Ohai::Log.error("shard_seed: Failed to get dmi property #{thing}: is dmidecode installed?")
|
30
|
+
raise "Failed to generate shard_seed"
|
29
31
|
end
|
30
32
|
|
31
33
|
def default_sources
|
@@ -77,11 +79,16 @@ Ohai.plugin(:ShardSeed) do
|
|
77
79
|
yield(src)
|
78
80
|
end
|
79
81
|
end
|
82
|
+
if data.empty?
|
83
|
+
Ohai::Log.error("shard_seed: Unable to generate seed! Either ensure 'dmidecode' is installed, or use 'Ohai.config[:plugin][:shard_seed][:sources]' to set different sources.")
|
84
|
+
raise "Failed to generate shard_seed"
|
85
|
+
end
|
80
86
|
shard_seed digest_algorithm.hexdigest(data)[0...7].to_i(16)
|
81
87
|
end
|
82
88
|
|
83
89
|
collect_data do
|
84
90
|
create_seed do |src|
|
91
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
85
92
|
raise "No such shard_seed source: #{src}"
|
86
93
|
end
|
87
94
|
end
|
@@ -99,6 +106,7 @@ Ohai.plugin(:ShardSeed) do
|
|
99
106
|
when :uuid
|
100
107
|
wmi.first_of("Win32_ComputerSystemProduct")["UUID"]
|
101
108
|
else
|
109
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
102
110
|
raise "No such shard_seed source: #{src}"
|
103
111
|
end
|
104
112
|
end
|
@@ -112,6 +120,7 @@ Ohai.plugin(:ShardSeed) do
|
|
112
120
|
when :uuid
|
113
121
|
hardware["platform_UUID"]
|
114
122
|
else
|
123
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
115
124
|
raise "No such shard_seed source: #{src}"
|
116
125
|
end
|
117
126
|
end
|
@@ -125,6 +134,7 @@ Ohai.plugin(:ShardSeed) do
|
|
125
134
|
when :uuid
|
126
135
|
get_dmi_property(dmi, :uuid)
|
127
136
|
else
|
137
|
+
Ohai::Log.error("shard_seed: No such source #{src}")
|
128
138
|
raise "No such shard_seed source: #{src}"
|
129
139
|
end
|
130
140
|
end
|
@@ -93,8 +93,8 @@ Ohai.plugin(:Virtualbox) do
|
|
93
93
|
so_cmd = "VBoxManage list --sorted #{query_type}"
|
94
94
|
logger.trace(so_cmd)
|
95
95
|
so = shell_out(so_cmd)
|
96
|
-
|
97
|
-
|
96
|
+
# raise an exception if the command fails
|
97
|
+
# so.error!
|
98
98
|
|
99
99
|
if so.exitstatus == 0
|
100
100
|
# break the result into paragraph blocks, on successive newlines
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Pete Higgins (pete@peterhiggins.org)
|
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(:DMI) do
|
20
|
+
provides "dmi"
|
21
|
+
|
22
|
+
# Map the linux component types to their rough Windows API equivalents
|
23
|
+
DMI_TO_WIN32OLE ||= {
|
24
|
+
chassis: "SystemEnclosure",
|
25
|
+
processor: "Processor",
|
26
|
+
bios: "Bios",
|
27
|
+
system: "ComputerSystemProduct",
|
28
|
+
base_board: "BaseBoard",
|
29
|
+
}.freeze
|
30
|
+
|
31
|
+
# This regex is in 3 parts for the different supported patterns in camel
|
32
|
+
# case names coming from the Windows API:
|
33
|
+
# * Typical camelcase, eg Depth, PartNumber, NumberOfPowerCords
|
34
|
+
# * Acronyms preceding camelcase, eg SMBIOSAssetTag
|
35
|
+
# * Acronyms that occur at the end of the name, eg SKU, DeviceID
|
36
|
+
#
|
37
|
+
# This cannot handle some property names, eg SMBIOSBIOSVersion.
|
38
|
+
# https://rubular.com/r/FBNtXod4wkZGAG
|
39
|
+
SPLIT_REGEX ||= /[A-Z][a-z0-9]+|[A-Z]{2,}(?=[A-Z][a-z0-9])|[A-Z]{2,}/.freeze
|
40
|
+
|
41
|
+
WINDOWS_TO_UNIX_KEYS ||= [
|
42
|
+
%w{vendor manufacturer},
|
43
|
+
%w{identifying_number serial_number},
|
44
|
+
%w{name family},
|
45
|
+
].freeze
|
46
|
+
|
47
|
+
collect_data(:windows) do
|
48
|
+
require "ohai/common/dmi"
|
49
|
+
require "wmi-lite/wmi"
|
50
|
+
wmi = WmiLite::Wmi.new
|
51
|
+
|
52
|
+
dmi Mash.new
|
53
|
+
|
54
|
+
# The Windows API returns property names in camel case, eg "SerialNumber",
|
55
|
+
# while `dmi` returns them as space separated strings, eg "Serial Number".
|
56
|
+
# `Ohai::Common::DMI.convenience_keys` expects property names in `dmi`'s
|
57
|
+
# format, so build two parallel hashes with the keys as they come from the
|
58
|
+
# Windows API and in a faked-out `dmi` version. After the call to
|
59
|
+
# `Ohai::Common::DMI.convenience_keys` replace the faked-out `dmi`
|
60
|
+
# collection with the one with the original property names.
|
61
|
+
DMI_TO_WIN32OLE.each do |dmi_key, ole_key|
|
62
|
+
wmi_objects = wmi.instances_of("Win32_#{ole_key}").map(&:wmi_ole_object)
|
63
|
+
|
64
|
+
split_name_properties = []
|
65
|
+
properties = []
|
66
|
+
|
67
|
+
wmi_objects.each do |wmi_object|
|
68
|
+
split_name_properties << Mash.new
|
69
|
+
properties << Mash.new
|
70
|
+
|
71
|
+
wmi_object.properties_.each do |property|
|
72
|
+
property_name = property.name
|
73
|
+
value = wmi_object.invoke(property_name)
|
74
|
+
|
75
|
+
split_name = property_name.scan(SPLIT_REGEX).join(" ")
|
76
|
+
split_name_properties.last[split_name] = value
|
77
|
+
properties.last[property_name] = value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
dmi[dmi_key] = Mash.new(all_records: split_name_properties, _all_records: properties)
|
82
|
+
end
|
83
|
+
|
84
|
+
Ohai::Common::DMI.convenience_keys(dmi)
|
85
|
+
|
86
|
+
dmi.each_value do |records|
|
87
|
+
records[:all_records] = records.delete(:_all_records)
|
88
|
+
|
89
|
+
WINDOWS_TO_UNIX_KEYS.each do |windows_key, unix_key|
|
90
|
+
records[unix_key] = records.delete(windows_key) if records.key?(windows_key)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -18,13 +18,11 @@
|
|
18
18
|
|
19
19
|
Ohai.plugin :SystemEnclosure do
|
20
20
|
provides "system_enclosure"
|
21
|
+
depends "dmi"
|
21
22
|
|
22
23
|
collect_data(:windows) do
|
23
|
-
require "wmi-lite/wmi"
|
24
24
|
system_enclosure Mash.new
|
25
|
-
|
26
|
-
|
27
|
-
system_enclosure[:manufacturer] = wmi_object.invoke("manufacturer")
|
28
|
-
system_enclosure[:serialnumber] = wmi_object.invoke("serialnumber")
|
25
|
+
system_enclosure[:manufacturer] = get_attribute(:dmi, :chassis, :manufacturer)
|
26
|
+
system_enclosure[:serialnumber] = get_attribute(:dmi, :chassis, :serial_number)
|
29
27
|
end
|
30
28
|
end
|
data/lib/ohai/version.rb
CHANGED
data/ohai.gemspec
CHANGED
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency "ipaddress"
|
25
25
|
s.add_dependency "wmi-lite", "~> 1.0"
|
26
26
|
s.add_dependency "ffi", "~> 1.9"
|
27
|
-
s.add_dependency "chef-config", ">= 12.8", "<
|
27
|
+
s.add_dependency "chef-config", ">= 12.8", "< 17"
|
28
|
+
s.add_dependency "chef-utils", ">= 16.0", "< 17"
|
28
29
|
# Note for ohai developers: If chef-config causes you grief, try:
|
29
30
|
# bundle install --with development
|
30
31
|
# this should work as long as chef is a development dependency in Gemfile.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 16.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|
@@ -177,7 +177,7 @@ dependencies:
|
|
177
177
|
version: '12.8'
|
178
178
|
- - "<"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
180
|
+
version: '17'
|
181
181
|
type: :runtime
|
182
182
|
prerelease: false
|
183
183
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -187,7 +187,27 @@ dependencies:
|
|
187
187
|
version: '12.8'
|
188
188
|
- - "<"
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: '
|
190
|
+
version: '17'
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: chef-utils
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '16.0'
|
198
|
+
- - "<"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '17'
|
201
|
+
type: :runtime
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '16.0'
|
208
|
+
- - "<"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '17'
|
191
211
|
description: Ohai profiles your system and emits JSON
|
192
212
|
email: adam@chef.io
|
193
213
|
executables:
|
@@ -254,6 +274,7 @@ files:
|
|
254
274
|
- lib/ohai/plugins/erlang.rb
|
255
275
|
- lib/ohai/plugins/eucalyptus.rb
|
256
276
|
- lib/ohai/plugins/filesystem.rb
|
277
|
+
- lib/ohai/plugins/fips.rb
|
257
278
|
- lib/ohai/plugins/freebsd/memory.rb
|
258
279
|
- lib/ohai/plugins/freebsd/network.rb
|
259
280
|
- lib/ohai/plugins/freebsd/platform.rb
|
@@ -271,8 +292,9 @@ files:
|
|
271
292
|
- lib/ohai/plugins/libvirt.rb
|
272
293
|
- lib/ohai/plugins/linode.rb
|
273
294
|
- lib/ohai/plugins/linux/block_device.rb
|
274
|
-
- lib/ohai/plugins/linux/fips.rb
|
275
295
|
- lib/ohai/plugins/linux/hostnamectl.rb
|
296
|
+
- lib/ohai/plugins/linux/interrupts.rb
|
297
|
+
- lib/ohai/plugins/linux/ipc.rb
|
276
298
|
- lib/ohai/plugins/linux/lsb.rb
|
277
299
|
- lib/ohai/plugins/linux/lspci.rb
|
278
300
|
- lib/ohai/plugins/linux/machineid.rb
|
@@ -280,6 +302,7 @@ files:
|
|
280
302
|
- lib/ohai/plugins/linux/memory.rb
|
281
303
|
- lib/ohai/plugins/linux/network.rb
|
282
304
|
- lib/ohai/plugins/linux/platform.rb
|
305
|
+
- lib/ohai/plugins/linux/selinux.rb
|
283
306
|
- lib/ohai/plugins/linux/sessions.rb
|
284
307
|
- lib/ohai/plugins/linux/sysctl.rb
|
285
308
|
- lib/ohai/plugins/linux/systemd_paths.rb
|
@@ -327,8 +350,8 @@ files:
|
|
327
350
|
- lib/ohai/plugins/uptime.rb
|
328
351
|
- lib/ohai/plugins/virtualbox.rb
|
329
352
|
- lib/ohai/plugins/vmware.rb
|
353
|
+
- lib/ohai/plugins/windows/dmi.rb
|
330
354
|
- lib/ohai/plugins/windows/drivers.rb
|
331
|
-
- lib/ohai/plugins/windows/fips.rb
|
332
355
|
- lib/ohai/plugins/windows/memory.rb
|
333
356
|
- lib/ohai/plugins/windows/network.rb
|
334
357
|
- lib/ohai/plugins/windows/platform.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c) 2016-2018 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
|
-
# After long discussion in IRC the "powers that be" have come to a concensus
|
20
|
-
# that there is no other Windows platforms exist that were not based on the
|
21
|
-
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
22
|
-
# platforms built upon the Windows_NT kernel and have access to win32 or win64
|
23
|
-
# subsystems.
|
24
|
-
|
25
|
-
Ohai.plugin(:Fips) do
|
26
|
-
provides "fips"
|
27
|
-
|
28
|
-
collect_data(:windows) do
|
29
|
-
fips Mash.new
|
30
|
-
|
31
|
-
require "openssl" unless defined?(OpenSSL)
|
32
|
-
if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE
|
33
|
-
fips["kernel"] = { "enabled" => true }
|
34
|
-
else
|
35
|
-
fips["kernel"] = { "enabled" => false }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|