ohai 17.1.0 → 17.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e30d1da39ec42887fd2cb097f22f5cfeb0662275c11abe0a5b647f317f9a44b
4
- data.tar.gz: 92330832131633f2c132857481898d6e3a0f3f966bfc122d91f33b416e400c1f
3
+ metadata.gz: 19b09efb3e8a7318b9401b9faf1fb17a472544ec5c7f45e7be090bcaafac9d93
4
+ data.tar.gz: d6deeb673906082bda7ab8ac7b4b1b5fb8dc41c22720ab4f4d47dfa994479be6
5
5
  SHA512:
6
- metadata.gz: 5ac054f71a2c0fae3566af336a08de3b5277c3bf7fc2e7c7fee076eb949018aba6aed602b28deffd9d97c6a543cb2cafefc42af0d820f6eaaa688e38867842d6
7
- data.tar.gz: 0b63b2a16cb614b7c33e90decce218654e1d92ce6a394a041dd8a906ce18ac65fda3028fdfd1523dc145d4ab7f3af8d868f3950384e2cc36d186c57d25478af4
6
+ metadata.gz: a8aec83f05fb402a2cc08efa9ce6d6fc81a0c2133bc57f60c9cbedff90236812e30e65373b5bb4813590ea2c7d5ae6c763caa58bbf56ef10c4ac5362df1dbc59
7
+ data.tar.gz: 948e93dddd2a283f43350795e15b46d83fe31db12d9f988bbe594882295fb7c57e576bc18be0a4db1d22002a177a6dddcce49f041dbc24cd777c75b59e62bce4
data/Gemfile CHANGED
@@ -3,20 +3,20 @@ source "https://rubygems.org"
3
3
 
4
4
  gemspec
5
5
 
6
- # pull these gems from master of chef/chef so that we're testing against what we will release
7
- gem "chef-config", git: "https://github.com/chef/chef", branch: "master", glob: "chef-config/chef-config.gemspec"
8
- gem "chef-utils", git: "https://github.com/chef/chef", branch: "master", glob: "chef-utils/chef-utils.gemspec"
6
+ # pull these gems from main of chef/chef so that we're testing against what we will release
7
+ gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec"
8
+ gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec"
9
9
 
10
10
  # NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
11
11
  group :development do
12
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
12
+ gem "chefstyle", "2.1.0"
13
13
  gem "ipaddr_extensions"
14
14
  gem "rake", ">= 10.1.0"
15
15
  gem "rspec-collection_matchers", "~> 1.0"
16
16
  gem "rspec-core", "~> 3.0"
17
17
  gem "rspec-expectations", "~> 3.0"
18
18
  gem "rspec-mocks", "~> 3.0"
19
- gem "rubocop-performance", "1.10.2"
19
+ gem "rubocop-performance", "1.11.5"
20
20
  gem "rubocop-rspec"
21
21
  end
22
22
 
data/lib/ohai/config.rb CHANGED
@@ -26,7 +26,7 @@ module Ohai
26
26
  Config = ChefConfig::Config
27
27
 
28
28
  # Reopens ChefConfig::Config to add Ohai configuration settings.
29
- # see: https://github.com/chef/chef/blob/master/lib/chef/config.rb
29
+ # see: https://github.com/chef/chef/blob/main/lib/chef/config.rb
30
30
  class Config
31
31
  config_context :ohai do
32
32
  default :disabled_plugins, []
@@ -23,7 +23,7 @@ module Ohai
23
23
  module ConstantHelper
24
24
 
25
25
  def remove_constants
26
- new_object_constants = Object.constants - @object_pristine.constants
26
+ new_object_constants = Object.constants - @object_pristine.constants - [ :SortedSet ]
27
27
  new_object_constants.each do |constant|
28
28
  Object.send(:remove_const, constant) unless Object.const_get(constant).is_a?(Module)
29
29
  end
@@ -41,10 +41,32 @@ module Ohai
41
41
  module Ec2Metadata
42
42
 
43
43
  EC2_METADATA_ADDR ||= "169.254.169.254"
44
- EC2_SUPPORTED_VERSIONS ||= %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
45
- 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
46
- 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02
47
- 2016-11-30 2018-08-17 2018-11-29 2019-10-01 2020-08-24 2020-11-01 }.freeze
44
+ EC2_SUPPORTED_VERSIONS ||= %w{ 1.0
45
+ 2007-01-19
46
+ 2007-03-01
47
+ 2007-08-29
48
+ 2007-10-10
49
+ 2007-12-15
50
+ 2008-02-01
51
+ 2008-09-01
52
+ 2009-04-04
53
+ 2011-01-01
54
+ 2011-05-01
55
+ 2012-01-12
56
+ 2014-02-25
57
+ 2014-11-05
58
+ 2015-10-20
59
+ 2016-04-19
60
+ 2016-06-30
61
+ 2016-09-02
62
+ 2018-03-28
63
+ 2018-08-17
64
+ 2018-09-24
65
+ 2019-10-01
66
+ 2020-10-27
67
+ 2021-01-03
68
+ 2021-03-23
69
+ 2021-07-15 }.freeze
48
70
  EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze
49
71
  EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze
50
72
  EC2_JSON_DIR ||= %w{iam}.freeze
@@ -32,6 +32,24 @@ module Ohai
32
32
  [2, 4, 6].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
33
33
  dec
34
34
  end
35
+
36
+ # This does a forward and reverse lookup on the hostname to return what should be
37
+ # the FQDN for the host determined by name lookup (generally DNS)
38
+ #
39
+ def canonicalize_hostname(hostname)
40
+ Addrinfo.getaddrinfo(hostname, nil).first.getnameinfo.first
41
+ end
42
+
43
+ def canonicalize_hostname_with_retries(hostname)
44
+ retries = 3
45
+ begin
46
+ canonicalize_hostname(hostname)
47
+ rescue
48
+ retries -= 1
49
+ retry if retries > 0
50
+ nil
51
+ end
52
+ end
35
53
  end
36
54
  end
37
55
  end
data/lib/ohai/mixin/os.rb CHANGED
@@ -82,13 +82,13 @@ module Ohai
82
82
  else
83
83
  # now we have something like an IPMI console that isn't Unix-like or Windows, presumably cannot run ruby, and
84
84
  # so we just trust the train O/S information.
85
- transport_connection.os
85
+ transport_connection.os.name
86
86
  end
87
87
  end
88
88
 
89
89
  # @api private
90
90
  def nonruby_target?
91
- transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows
91
+ transport_connection && !transport_connection.os.unix? && !transport_connection.os.windows?
92
92
  end
93
93
 
94
94
  # @api private
@@ -499,7 +499,7 @@ Ohai.plugin(:CPU) do
499
499
 
500
500
  cpu[:total] = shell_out("pmcycles -m").stdout.lines.length
501
501
 
502
- # The below is only relevent on an LPAR
502
+ # The below is only relevant on an LPAR
503
503
  if shell_out("uname -W").stdout.strip == "0"
504
504
 
505
505
  # At least one CPU will be available, but we'll wait to increment this later.
@@ -26,7 +26,11 @@
26
26
  # limitations under the License.
27
27
  #
28
28
 
29
+ require_relative "../mixin/network_helper"
30
+
29
31
  Ohai.plugin(:Hostname) do
32
+ include Ohai::Mixin::NetworkHelper
33
+
30
34
  provides "domain", "hostname", "fqdn", "machinename"
31
35
 
32
36
  # hostname : short hostname
@@ -42,38 +46,8 @@ Ohai.plugin(:Hostname) do
42
46
  end
43
47
 
44
48
  # forward and reverse lookup to canonicalize FQDN (hostname -f equivalent)
45
- # this is ipv6-safe, works on ruby 1.8.7+
46
49
  def resolve_fqdn
47
- require "socket" unless defined?(Socket)
48
- require "ipaddr" unless defined?(IPAddr)
49
-
50
- hostname = from_cmd("hostname")
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
73
- iaddr = IPAddr.new(addrinfo[3])
74
- Socket.gethostbyaddr(iaddr.hton)[0]
75
- rescue
76
- nil
50
+ canonicalize_hostname_with_retries(from_cmd("hostname"))
77
51
  end
78
52
 
79
53
  def collect_domain
@@ -119,58 +93,21 @@ Ohai.plugin(:Hostname) do
119
93
  collect_data(:darwin) do
120
94
  hostname from_cmd("hostname -s")
121
95
  machinename from_cmd("hostname")
122
- begin
123
- our_fqdn = resolve_fqdn
124
- # Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
125
- # returns a blank string. WTF.
126
- if our_fqdn.nil? || our_fqdn.empty?
127
- logger.trace("Plugin Hostname: hostname returned an empty string, retrying once.")
128
- our_fqdn = resolve_fqdn
129
- end
130
-
131
- if our_fqdn.nil? || our_fqdn.empty?
132
- logger.trace("Plugin Hostname: hostname returned an empty string twice and will" +
133
- "not be set.")
134
- else
135
- fqdn our_fqdn
136
- end
137
- rescue
138
- logger.trace(
139
- "Plugin Hostname: hostname returned an error, probably no domain set"
140
- )
141
- end
96
+ fqdn resolve_fqdn
142
97
  domain collect_domain
143
98
  end
144
99
 
145
100
  collect_data(:freebsd) do
146
101
  hostname from_cmd("hostname -s")
147
102
  machinename from_cmd("hostname")
148
- fqdn from_cmd("hostname -f")
103
+ fqdn resolve_fqdn
149
104
  collect_domain
150
105
  end
151
106
 
152
107
  collect_data(:linux) do
153
108
  hostname from_cmd("hostname -s")
154
109
  machinename from_cmd("hostname")
155
- begin
156
- our_fqdn = from_cmd("hostname --fqdn")
157
- # Sometimes... very rarely, but sometimes, 'hostname --fqdn' falsely
158
- # returns a blank string. WTF.
159
- if our_fqdn.nil? || our_fqdn.empty?
160
- logger.trace("Plugin Hostname: hostname --fqdn returned an empty string, retrying " +
161
- "once.")
162
- our_fqdn = from_cmd("hostname --fqdn")
163
- end
164
-
165
- if our_fqdn.nil? || our_fqdn.empty?
166
- logger.trace("Plugin Hostname: hostname --fqdn returned an empty string twice and " +
167
- "will not be set.")
168
- else
169
- fqdn our_fqdn
170
- end
171
- rescue
172
- logger.trace("Plugin Hostname: hostname --fqdn returned an error, probably no domain set")
173
- end
110
+ fqdn resolve_fqdn
174
111
  domain collect_domain
175
112
  end
176
113
 
@@ -190,22 +127,7 @@ Ohai.plugin(:Hostname) do
190
127
 
191
128
  hostname host["dnshostname"].to_s
192
129
  machinename host["name"].to_s
193
-
194
- info = Socket.gethostbyname(Socket.gethostname)
195
- if /.+?\.(.*)/.match?(info.first)
196
- fqdn info.first
197
- else
198
- # host is not in dns. optionally use:
199
- # C:\WINDOWS\system32\drivers\etc\hosts
200
- info[3..info.length].reverse_each do |addr|
201
- hostent = Socket.gethostbyaddr(addr)
202
- if /.+?\.(.*)/.match?(hostent.first)
203
- fqdn hostent.first
204
- break
205
- end
206
- end
207
- fqdn info.first unless fqdn
208
- end
130
+ fqdn canonicalize_hostname_with_retries(Socket.gethostname)
209
131
  domain collect_domain
210
132
  end
211
133
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Author:: Song Liu <song@kernel.org>
4
+ # Copyright:: Copyright (c) 2021 Facebook, Inc.
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(:Livepatch) do
21
+ provides "livepatch"
22
+
23
+ collect_data(:linux) do
24
+ if file_exist?("/sys/kernel/livepatch")
25
+ patches = Mash.new
26
+ dir_glob("/sys/kernel/livepatch/*").each do |livepatch_dir|
27
+ dir = File.basename(livepatch_dir)
28
+ patches[dir] = Mash.new
29
+ %w{enabled transition}.each do |check|
30
+ if file_exist?("/sys/kernel/livepatch/#{dir}/#{check}")
31
+ file_open("/sys/kernel/livepatch/#{dir}/#{check}") { |f| patches[dir][check] = f.read_nonblock(1024).strip }
32
+ end
33
+ end
34
+ livepatch patches
35
+ end
36
+ end
37
+ end
38
+ end
@@ -80,7 +80,7 @@ Ohai.plugin(:Network) do
80
80
  line.strip!
81
81
  logger.trace("Plugin Network: Parsing #{line}")
82
82
  if /\\/.match?(line)
83
- parts = line.split('\\')
83
+ parts = line.split("\\")
84
84
  route_dest = parts.shift.strip
85
85
  route_endings = parts
86
86
  elsif line =~ /^([^\s]+)\s(.*)$/
@@ -137,7 +137,7 @@ Ohai.plugin(:Platform) do
137
137
  when /ubuntu/, /debian/, /linuxmint/, /raspbian/, /cumulus/, /kali/, /pop/
138
138
  # apt-get+dpkg almost certainly goes here
139
139
  "debian"
140
- when /centos/, /redhat/, /oracle/, /almalinux/, /rocky/, /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
+ when /centos/, /redhat/, /oracle/, /almalinux/, /rocky/, /scientific/, /enterpriseenterprise/, /xenserver/, /xcp-ng/, /cloudlinux/, /alibabalinux/, /sangoma/, /clearos/, /parallels/, /ibm_powerkvm/, /nexus_centos/, /bigip/, /virtuozzo/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
141
141
  # NOTE: "rhel" should be reserved exclusively for recompiled rhel versions that are nearly perfectly compatible down to the platform_version.
142
142
  # The operating systems that are "rhel" should all be as compatible as rhel7 = centos7 = oracle7 = scientific7 (98%-ish core RPM version compatibility
143
143
  # and the version numbers MUST track the upstream). The appropriate EPEL version repo should work nearly perfectly. Some variation like the
@@ -0,0 +1,61 @@
1
+ #
2
+ # Author:: Matthew Massey <matthewmassey@fb.com>
3
+ # Copyright:: Copyright (c) 2021 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(:Tc) do
20
+ provides "tc"
21
+ optional true
22
+
23
+ collect_data(:linux) do
24
+ tc_path = which("tc")
25
+ if tc_path
26
+ cmd = "#{tc_path} qdisc show"
27
+ tc_output = shell_out(cmd)
28
+
29
+ tc_data = Mash.new
30
+ tc_data[:qdisc] = Mash.new
31
+
32
+ tc_output.stdout.split("\n").each do |line|
33
+ line = line.strip
34
+ if /dev (\w+)/ =~ line
35
+ dev = $1
36
+ tc_data[:qdisc][dev] ||= Mash.new
37
+ else
38
+ next
39
+ end
40
+ if /qdisc (\w+)/ =~ line
41
+ qdisc = $1
42
+ tc_data[:qdisc][dev][:qdiscs] ||= []
43
+ tc_data[:qdisc][dev][:qdiscs] << Mash.new
44
+ qdisc_idx = tc_data[:qdisc][dev][:qdiscs].length - 1
45
+ tc_data[:qdisc][dev][:qdiscs][qdisc_idx] ||= Mash.new
46
+ tc_data[:qdisc][dev][:qdiscs][qdisc_idx][:type] = qdisc
47
+ tc_data[:qdisc][dev][:qdiscs][qdisc_idx][:parms] ||= Mash.new
48
+ else
49
+ next
50
+ end
51
+ if qdisc == "fq" && /buckets (\d+)/ =~ line
52
+ buckets = $1.to_i
53
+ tc_data[:qdisc][dev][:qdiscs][qdisc_idx][:parms][:buckets] = buckets
54
+ end
55
+ end
56
+ tc tc_data
57
+ else
58
+ logger.trace("Plugin Tc: Could not find tc. Skipping plugin.")
59
+ end
60
+ end
61
+ end
@@ -40,6 +40,12 @@ Ohai.plugin(:OS) do
40
40
 
41
41
  collect_data(:target) do
42
42
  os collect_os
43
+ os_version "unknown"
44
+ end
45
+
46
+ collect_data(:api) do
47
+ os collect_os
48
+ os_version "unknown"
43
49
  end
44
50
 
45
51
  collect_data do
@@ -134,9 +134,9 @@ Ohai.plugin(:Packages) do
134
134
  require "win32/registry" unless defined?(Win32::Registry)
135
135
  packages Mash.new
136
136
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
137
- collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall')
137
+ # on 64 bit systems, 32 bit programs are stored here moved before HKEY_CURRENT_USER otherwise it is not collected (impacts both ohai 16 & 17)
138
138
  collect_programs_from_registry_key(Win32::Registry::HKEY_LOCAL_MACHINE, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
139
- # on 64 bit systems, 32 bit programs are stored here
139
+ collect_programs_from_registry_key(Win32::Registry::HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall') rescue nil
140
140
  end
141
141
 
142
142
  collect_data(:aix) do
data/lib/ohai/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ohai
21
21
  OHAI_ROOT = File.expand_path(__dir__)
22
- VERSION = "17.1.0"
22
+ VERSION = "17.7.5"
23
23
  end
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: 17.1.0
4
+ version: 17.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-03 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -302,6 +302,7 @@ files:
302
302
  - lib/ohai/plugins/linux/hostnamectl.rb
303
303
  - lib/ohai/plugins/linux/interrupts.rb
304
304
  - lib/ohai/plugins/linux/ipc.rb
305
+ - lib/ohai/plugins/linux/livepatch.rb
305
306
  - lib/ohai/plugins/linux/lsb.rb
306
307
  - lib/ohai/plugins/linux/lspci.rb
307
308
  - lib/ohai/plugins/linux/machineid.rb
@@ -314,6 +315,7 @@ files:
314
315
  - lib/ohai/plugins/linux/sessions.rb
315
316
  - lib/ohai/plugins/linux/sysctl.rb
316
317
  - lib/ohai/plugins/linux/systemd_paths.rb
318
+ - lib/ohai/plugins/linux/tc.rb
317
319
  - lib/ohai/plugins/linux/virtualization.rb
318
320
  - lib/ohai/plugins/lua.rb
319
321
  - lib/ohai/plugins/mono.rb