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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 168be10defab5e91f8da06ce4d101a461ed13a2051d4b6901c3039571c7a3066
|
4
|
+
data.tar.gz: 8783ddbdc49208974d09cfc7e708760402248719baaf2a1a8dce28e8a14902bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5781908ba60b11f68397c10693d6c084e1eb021dc5a6b1348448b712225322295cc5b510dc41e9feecbf1a463d23f47773428ce540c138b43a2c6fd9ced079a4
|
7
|
+
data.tar.gz: 50a9ba71dca6681a84536c1f443653dc4d78172ded2fffa9022ad8ed8e577a0dc3e1bc6329b021438fe3ee6d2d62d1154093928fb3fb53957df38363f0bf92c2
|
data/Gemfile
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source "https://rubygems.org"
|
2
3
|
|
3
4
|
gemspec
|
4
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", glob: "chef-config/chef-config.gemspec"
|
8
|
+
gem "chef-utils", git: "https://github.com/chef/chef", glob: "chef-utils/chef-utils.gemspec"
|
9
|
+
|
5
10
|
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
|
6
11
|
group :development do
|
7
12
|
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
@@ -11,19 +16,13 @@ group :development do
|
|
11
16
|
gem "rspec-core", "~> 3.0"
|
12
17
|
gem "rspec-expectations", "~> 3.0"
|
13
18
|
gem "rspec-mocks", "~> 3.0"
|
14
|
-
gem "rubocop-performance", "1.
|
19
|
+
gem "rubocop-performance", "1.9.0"
|
15
20
|
gem "rubocop-rspec"
|
16
21
|
end
|
17
22
|
|
18
|
-
group :docs do
|
19
|
-
gem "github-markup"
|
20
|
-
gem "redcarpet"
|
21
|
-
gem "yard"
|
22
|
-
end
|
23
|
-
|
24
23
|
group :debug do
|
25
24
|
gem "pry"
|
26
25
|
gem "pry-byebug"
|
27
|
-
gem "pry-stack_explorer"
|
26
|
+
gem "pry-stack_explorer"
|
28
27
|
gem "rb-readline"
|
29
28
|
end
|
data/bin/ohai
CHANGED
data/lib/ohai.rb
CHANGED
data/lib/ohai/application.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
|
3
4
|
# Copyright:: Copyright (c) 2009 Mathieu Sauve-Frankel.
|
@@ -56,6 +57,15 @@ class Ohai::Application
|
|
56
57
|
description: "Set the log file location, defaults to STDOUT - recommended for daemonizing",
|
57
58
|
proc: nil
|
58
59
|
|
60
|
+
option :target,
|
61
|
+
short: "-t TARGET",
|
62
|
+
long: "--target TARGET",
|
63
|
+
description: "Target Ohai against a remote system or device",
|
64
|
+
proc: lambda { |target|
|
65
|
+
Ohai::Log.warn "-- EXPERIMENTAL -- Target mode activated -- EXPERIMENTAL --"
|
66
|
+
target
|
67
|
+
}
|
68
|
+
|
59
69
|
option :help,
|
60
70
|
short: "-h",
|
61
71
|
long: "--help",
|
@@ -93,9 +103,39 @@ class Ohai::Application
|
|
93
103
|
|
94
104
|
load_workstation_config
|
95
105
|
|
106
|
+
merge_configs
|
107
|
+
|
108
|
+
if config[:target]
|
109
|
+
Ohai::Config.target_mode.host = config[:target]
|
110
|
+
if URI.parse(Ohai::Config.target_mode.host).scheme
|
111
|
+
train_config = Train.unpack_target_from_uri(Ohai::Config.target_mode.host)
|
112
|
+
Ohai::Config.target_mode = train_config
|
113
|
+
end
|
114
|
+
Ohai::Config.target_mode.enabled = true
|
115
|
+
Ohai::Config.node_name = Ohai::Config.target_mode.host unless Ohai::Config.node_name
|
116
|
+
end
|
117
|
+
|
96
118
|
Ohai::Log.init(Ohai.config[:log_location])
|
97
119
|
end
|
98
120
|
|
121
|
+
# @api private
|
122
|
+
def config_file_defaults
|
123
|
+
Ohai::Config.save(true)
|
124
|
+
end
|
125
|
+
|
126
|
+
# @api private
|
127
|
+
def config_file_settings
|
128
|
+
Ohai::Config.save(false)
|
129
|
+
end
|
130
|
+
|
131
|
+
# See lib/chef/knife.rb in the chef/chef github repo
|
132
|
+
#
|
133
|
+
# @api private
|
134
|
+
def merge_configs
|
135
|
+
config.replace(config_file_defaults.merge(default_config).merge(config_file_settings).merge(config))
|
136
|
+
Ohai::Config.merge!(config) # make them both the same
|
137
|
+
end
|
138
|
+
|
99
139
|
# Passes config and attributes arguments to Ohai::System then prints the results.
|
100
140
|
# Called by the run method after config / logging have been initialized
|
101
141
|
#
|
data/lib/ohai/common/dmi.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Kurt Yoder (ktyopscode@yoderhome.com)
|
3
4
|
# Copyright:: Copyright (c) 2010 Kurt Yoder
|
@@ -76,11 +77,11 @@ module Ohai
|
|
76
77
|
# away some of the less useful IDs
|
77
78
|
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ].freeze
|
78
79
|
|
79
|
-
# the
|
80
|
+
# the allowlisted DMI IDs. This is combination of the defaults + any additional
|
80
81
|
# IDs defined in the :additional_dmi_ids config
|
81
82
|
#
|
82
83
|
# @return [Array] the list of DMI IDs to capture
|
83
|
-
def
|
84
|
+
def allowlisted_ids
|
84
85
|
if Ohai.config[:additional_dmi_ids]
|
85
86
|
if [ Integer, Array ].include?(Ohai.config[:additional_dmi_ids].class)
|
86
87
|
return ID_TO_CAPTURE + Array(Ohai.config[:additional_dmi_ids])
|
@@ -91,6 +92,10 @@ module Ohai
|
|
91
92
|
ID_TO_CAPTURE
|
92
93
|
end
|
93
94
|
|
95
|
+
##
|
96
|
+
# @deprecated Use the `allowlisted_ids` method instead.
|
97
|
+
alias whitelisted_ids allowlisted_ids
|
98
|
+
|
94
99
|
# the human readable description from a DMI ID
|
95
100
|
#
|
96
101
|
# @param id [String, Integer] the ID to lookup
|
@@ -152,7 +157,7 @@ module Ohai
|
|
152
157
|
end
|
153
158
|
end
|
154
159
|
|
155
|
-
module_function :id_lookup, :convenience_keys, :whitelisted_ids
|
160
|
+
module_function :id_lookup, :convenience_keys, :allowlisted_ids, :whitelisted_ids
|
156
161
|
end
|
157
162
|
end
|
158
163
|
end
|
data/lib/ohai/config.rb
CHANGED
data/lib/ohai/dsl.rb
CHANGED
data/lib/ohai/dsl/plugin.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
4
|
# Author:: Claire McQuin (<claire@chef.io>)
|
@@ -22,6 +23,7 @@ require_relative "../mixin/os"
|
|
22
23
|
require_relative "../mixin/shell_out"
|
23
24
|
require_relative "../mixin/seconds_to_human"
|
24
25
|
require_relative "../mixin/which"
|
26
|
+
require_relative "../mixin/train_helpers"
|
25
27
|
require_relative "../hints"
|
26
28
|
|
27
29
|
module Ohai
|
@@ -86,10 +88,12 @@ module Ohai
|
|
86
88
|
include Ohai::Mixin::ShellOut
|
87
89
|
include Ohai::Mixin::SecondsToHuman
|
88
90
|
include Ohai::Mixin::Which
|
91
|
+
include Ohai::Mixin::TrainHelpers
|
89
92
|
|
90
93
|
attr_reader :data
|
91
94
|
attr_reader :failed
|
92
95
|
attr_reader :logger
|
96
|
+
attr_accessor :transport_connection
|
93
97
|
|
94
98
|
def initialize(data, logger)
|
95
99
|
@data = data
|
@@ -98,6 +102,10 @@ module Ohai
|
|
98
102
|
@failed = false
|
99
103
|
end
|
100
104
|
|
105
|
+
def target_mode?
|
106
|
+
!!@transport_connection
|
107
|
+
end
|
108
|
+
|
101
109
|
def run
|
102
110
|
@has_run = true
|
103
111
|
|
@@ -210,7 +218,7 @@ module Ohai
|
|
210
218
|
def safe_get_attribute(*keys)
|
211
219
|
keys.inject(@data) do |attrs, key|
|
212
220
|
unless attrs.nil? || attrs.is_a?(Array) || attrs.is_a?(Hash)
|
213
|
-
raise TypeError
|
221
|
+
raise TypeError, "Expected Hash but got #{attrs.class}."
|
214
222
|
end
|
215
223
|
|
216
224
|
attrs[key]
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Serdar Sutay (<serdar@chef.io>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -46,7 +47,8 @@ module Ohai
|
|
46
47
|
:version7
|
47
48
|
end
|
48
49
|
|
49
|
-
#
|
50
|
+
# The source of the plugin on disk. This is an array since a plugin may exist for multiple
|
51
|
+
# oses and this would include each of those os specific file paths
|
50
52
|
#
|
51
53
|
# @return [Array]
|
52
54
|
def self.sources
|
@@ -61,7 +63,7 @@ module Ohai
|
|
61
63
|
@depends_attrs ||= []
|
62
64
|
end
|
63
65
|
|
64
|
-
# A block per
|
66
|
+
# A block per os for actually performing data collection constructed
|
65
67
|
# by the collect_data method
|
66
68
|
#
|
67
69
|
# @return [Mash]
|
@@ -101,15 +103,16 @@ module Ohai
|
|
101
103
|
!!@optional
|
102
104
|
end
|
103
105
|
|
104
|
-
# define data collection methodology per
|
106
|
+
# define data collection methodology per os
|
105
107
|
#
|
106
|
-
# @param
|
107
|
-
# @param
|
108
|
-
#
|
109
|
-
def self.collect_data(
|
110
|
-
[
|
111
|
-
|
112
|
-
|
108
|
+
# @param os [Array<Symbol>] the list of oses to collect data for
|
109
|
+
# @param block [block] the actual code to collect data for the specified os
|
110
|
+
#
|
111
|
+
def self.collect_data(*os_list, &block)
|
112
|
+
os_list = [ :default ] if os_list.empty?
|
113
|
+
os_list.flatten.each do |os|
|
114
|
+
Ohai::Log.warn("collect_data already defined on os '#{os}' for #{self}, last plugin seen will be used") if data_collector.key?(os)
|
115
|
+
data_collector[os] = block
|
113
116
|
end
|
114
117
|
end
|
115
118
|
|
@@ -120,12 +123,22 @@ module Ohai
|
|
120
123
|
|
121
124
|
def run_plugin
|
122
125
|
collector = self.class.data_collector
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
os = collect_os
|
127
|
+
|
128
|
+
# :default - means any remote or local unix or windows host
|
129
|
+
# :target - means any remote API which is not unix/windows or otherwise rubyable (cisco switches, IPMI console, HTTP API, etc)
|
130
|
+
#
|
131
|
+
# Do not be confused by the fact that collectors tagged :target do not run against e.g. target-mode ubuntu boxes, that is not
|
132
|
+
# what :target is intended for. Also, do not be confused by the fact that collectors tagged :default do not run by default against
|
133
|
+
# pure-target mode targets like switches. That is all intended behavior, the names are problematic. The :default nomenclature was
|
134
|
+
# invented 10 years before target mode and we are stuck with it.
|
135
|
+
#
|
136
|
+
if collector.key?(os)
|
137
|
+
instance_eval(&collector[os])
|
138
|
+
elsif collector.key?(:default) && !nonruby_target?
|
128
139
|
instance_eval(&collector[:default])
|
140
|
+
elsif collector.key?(:target) && nonruby_target?
|
141
|
+
instance_eval(&collector[:target])
|
129
142
|
else
|
130
143
|
logger.trace("Plugin #{name}: No data to collect. Skipping...")
|
131
144
|
end
|
@@ -182,8 +195,6 @@ module Ohai
|
|
182
195
|
# key? to avoid falsely instantiating a configuration hash.
|
183
196
|
if Ohai.config[:plugin].key?(snake_case_name)
|
184
197
|
Ohai.config[:plugin][snake_case_name]
|
185
|
-
else
|
186
|
-
nil
|
187
198
|
end
|
188
199
|
end
|
189
200
|
end
|
data/lib/ohai/exception.rb
CHANGED
data/lib/ohai/hints.rb
CHANGED
data/lib/ohai/log.rb
CHANGED
data/lib/ohai/mash.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
3
4
|
# Copyright:: Copyright (c) Chef Software Inc.
|
@@ -31,12 +32,12 @@ module Ohai
|
|
31
32
|
#
|
32
33
|
module AzureMetadata
|
33
34
|
|
34
|
-
AZURE_METADATA_ADDR ||= "169.254.169.254"
|
35
|
+
AZURE_METADATA_ADDR ||= "169.254.169.254"
|
35
36
|
|
36
37
|
# it's important that the newer versions are at the end of this array so we can skip sorting it
|
37
38
|
AZURE_SUPPORTED_VERSIONS ||= %w{ 2017-04-02 2017-08-01 2017-12-01 2018-02-01 2018-04-02
|
38
|
-
|
39
|
-
|
39
|
+
2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
|
40
|
+
2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
|
40
41
|
|
41
42
|
def best_api_version
|
42
43
|
@api_version ||= begin
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Copyright:: Copyright (c) Chef Software Inc.
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -16,6 +17,7 @@
|
|
16
17
|
#
|
17
18
|
|
18
19
|
require_relative "../config"
|
20
|
+
require "singleton" unless defined?(Singleton)
|
19
21
|
|
20
22
|
module Ohai
|
21
23
|
module Mixin
|
@@ -32,7 +34,18 @@ module Ohai
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def __transport_connection
|
35
|
-
|
37
|
+
transport_connection
|
38
|
+
end
|
39
|
+
|
40
|
+
# because of target mode we cache the PATH to avoid massive amounts of `echo $PATH` remote queries
|
41
|
+
#
|
42
|
+
def __env_path
|
43
|
+
PathCache.instance.path_cache ||= super
|
44
|
+
end
|
45
|
+
|
46
|
+
class PathCache
|
47
|
+
include Singleton
|
48
|
+
attr_accessor :path_cache
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
data/lib/ohai/mixin/command.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
$stderr.puts "WARN: Ohai::Mixin::Command is deprecated, please use Ohai::Mixin::ShellOut or remove if the reference is unnecessary"
|
2
3
|
require_relative "shell_out"
|
3
4
|
Ohai::Mixin::Command = Ohai::Mixin::ShellOut unless defined?(Ohai::Mixin::Command)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
# Author:: Dylan Page (<dpage@digitalocean.com>)
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -20,8 +21,8 @@ module Ohai
|
|
20
21
|
module Mixin
|
21
22
|
module DOMetadata
|
22
23
|
|
23
|
-
DO_METADATA_ADDR ||= "169.254.169.254"
|
24
|
-
DO_METADATA_URL ||= "/metadata/v1.json"
|
24
|
+
DO_METADATA_ADDR ||= "169.254.169.254"
|
25
|
+
DO_METADATA_URL ||= "/metadata/v1.json"
|
25
26
|
|
26
27
|
def http_client
|
27
28
|
Net::HTTP.start(DO_METADATA_ADDR).tap { |h| h.read_timeout = 6 }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
4
|
# Author:: Benjamin Black (<bb@chef.io>)
|
@@ -39,10 +40,10 @@ module Ohai
|
|
39
40
|
#
|
40
41
|
module Ec2Metadata
|
41
42
|
|
42
|
-
EC2_METADATA_ADDR ||= "169.254.169.254"
|
43
|
+
EC2_METADATA_ADDR ||= "169.254.169.254"
|
43
44
|
EC2_SUPPORTED_VERSIONS ||= %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
|
44
|
-
|
45
|
-
|
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 }.freeze
|
46
47
|
EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze
|
47
48
|
EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze
|
48
49
|
EC2_JSON_DIR ||= %w{iam}.freeze
|
@@ -57,7 +58,7 @@ module Ohai
|
|
57
58
|
elsif response.code != "200"
|
58
59
|
raise "Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)"
|
59
60
|
end
|
60
|
-
#
|
61
|
+
# NOTE: Sorting the list of versions may have unintended consequences in
|
61
62
|
# non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12.
|
62
63
|
versions = response.body.split("\n").sort
|
63
64
|
until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)
|
@@ -118,7 +119,7 @@ module Ohai
|
|
118
119
|
else
|
119
120
|
metadata_get(key, best_api_version)
|
120
121
|
end
|
121
|
-
elsif (
|
122
|
+
elsif (!key.eql?(id)) && (!key.eql?("/"))
|
122
123
|
name = key[0..-2]
|
123
124
|
sym = metadata_key(name)
|
124
125
|
if EC2_ARRAY_DIR.include?(name)
|
@@ -142,8 +143,8 @@ module Ohai
|
|
142
143
|
key = expand_path(o)
|
143
144
|
if key[-1..-1] != "/"
|
144
145
|
retr_meta = metadata_get("#{id}#{key}", api_version)
|
145
|
-
metadata[metadata_key(key)] = retr_meta
|
146
|
-
elsif
|
146
|
+
metadata[metadata_key(key)] = retr_meta || ""
|
147
|
+
elsif !key.eql?("/")
|
147
148
|
metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version)
|
148
149
|
end
|
149
150
|
end
|
@@ -159,11 +160,11 @@ module Ohai
|
|
159
160
|
key = expand_path(o)
|
160
161
|
if key[-1..-1] != "/"
|
161
162
|
retr_meta = metadata_get("#{id}#{key}", api_version)
|
162
|
-
data = retr_meta
|
163
|
+
data = retr_meta || ""
|
163
164
|
json = String(data)
|
164
165
|
parser = FFI_Yajl::Parser.new
|
165
166
|
metadata[metadata_key(key)] = parser.parse(json)
|
166
|
-
elsif
|
167
|
+
elsif !key.eql?("/")
|
167
168
|
metadata[key[0..-2]] = fetch_json_dir_metadata("#{id}#{key}", api_version)
|
168
169
|
end
|
169
170
|
end
|