openfact 5.7.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/docs/generate.rb +1 -5
- data/lib/facter/custom_facts/core/aggregate.rb +2 -4
- data/lib/facter/custom_facts/core/execution/base.rb +10 -6
- data/lib/facter/custom_facts/core/execution/posix.rb +5 -5
- data/lib/facter/custom_facts/core/execution/windows.rb +5 -5
- data/lib/facter/custom_facts/core/execution.rb +3 -1
- data/lib/facter/custom_facts/core/resolvable.rb +4 -6
- data/lib/facter/custom_facts/util/collection.rb +0 -2
- data/lib/facter/custom_facts/util/config.rb +1 -1
- data/lib/facter/custom_facts/util/directory_loader.rb +2 -6
- data/lib/facter/custom_facts/util/fact.rb +2 -21
- data/lib/facter/custom_facts/util/parser.rb +5 -5
- data/lib/facter/custom_facts/util/resolution.rb +15 -8
- data/lib/facter/facts/aix/networking/interfaces.rb +1 -1
- data/lib/facter/facts/freebsd/ec2_metadata.rb +1 -1
- data/lib/facter/facts/freebsd/ec2_userdata.rb +1 -1
- data/lib/facter/facts/linux/az_metadata.rb +1 -1
- data/lib/facter/facts/linux/dhcp_servers.rb +1 -1
- data/lib/facter/facts/linux/ec2_metadata.rb +1 -1
- data/lib/facter/facts/linux/ec2_userdata.rb +1 -1
- data/lib/facter/facts/macosx/dhcp_servers.rb +1 -1
- data/lib/facter/facts/openbsd/ec2_metadata.rb +1 -1
- data/lib/facter/facts/openbsd/ec2_userdata.rb +1 -1
- data/lib/facter/facts/solaris/dhcp_servers.rb +1 -1
- data/lib/facter/facts/windows/az_metadata.rb +1 -1
- data/lib/facter/facts/windows/dhcp_servers.rb +1 -1
- data/lib/facter/facts/windows/ec2_metadata.rb +1 -1
- data/lib/facter/facts/windows/ec2_userdata.rb +1 -1
- data/lib/facter/framework/cli/cli.rb +6 -6
- data/lib/facter/framework/core/cache_manager.rb +3 -6
- data/lib/facter/framework/core/options/option_store.rb +1 -1
- data/lib/facter/framework/core/options.rb +1 -1
- data/lib/facter/framework/formatters/legacy_fact_formatter.rb +1 -1
- data/lib/facter/models/fact_collection.rb +1 -3
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/mountpoints.rb +3 -3
- data/lib/facter/resolvers/aix/networking.rb +1 -1
- data/lib/facter/resolvers/az.rb +1 -1
- data/lib/facter/resolvers/ec2.rb +1 -1
- data/lib/facter/resolvers/gce.rb +1 -1
- data/lib/facter/resolvers/linux/docker_uptime.rb +1 -1
- data/lib/facter/resolvers/linux/hostname.rb +1 -1
- data/lib/facter/resolvers/linux/processors.rb +1 -1
- data/lib/facter/resolvers/macosx/mountpoints.rb +1 -0
- data/lib/facter/resolvers/mountpoints.rb +1 -1
- data/lib/facter/resolvers/networking.rb +1 -2
- data/lib/facter/resolvers/path.rb +1 -1
- data/lib/facter/resolvers/selinux.rb +1 -1
- data/lib/facter/resolvers/solaris/ffi/functions.rb +1 -0
- data/lib/facter/resolvers/solaris/mountpoints.rb +1 -0
- data/lib/facter/resolvers/solaris/networking.rb +1 -2
- data/lib/facter/resolvers/solaris/os_release.rb +1 -1
- data/lib/facter/resolvers/solaris/processors.rb +1 -1
- data/lib/facter/resolvers/uname.rb +3 -3
- data/lib/facter/resolvers/windows/processors.rb +6 -6
- data/lib/facter/resolvers/windows/ssh.rb +1 -1
- data/lib/facter/resolvers/windows/system32.rb +1 -1
- data/lib/facter/resolvers/windows/timezone.rb +1 -1
- data/lib/facter/resolvers/windows/uptime.rb +1 -2
- data/lib/facter/resolvers/windows/virtualization.rb +1 -2
- data/lib/facter/resolvers/windows/win_os_description.rb +1 -2
- data/lib/facter/util/api_debugger.rb +1 -1
- data/lib/facter/util/facts/posix/virtual_detector.rb +2 -2
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/facts/uptime_parser.rb +9 -9
- data/lib/facter/util/macosx/system_profile_executor.rb +1 -1
- data/lib/facter/util/resolvers/ffi/hostname.rb +1 -0
- data/lib/facter/util/resolvers/ffi/load_averages.rb +1 -0
- data/lib/facter/util/resolvers/networking/networking.rb +3 -3
- data/lib/facter/version.rb +1 -1
- data/lib/facter.rb +1 -1
- metadata +9 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e52f6542f74fd6ae174527c89973ccf46aa5542e44d9f397bc800fbc92d357bd
|
|
4
|
+
data.tar.gz: ce3214f7c6274abcff1fb2606963f551f207a2aa0a67016b01614468a685f42a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 864114f9fa9ed5f294a306aa3d7d0e10d069bc3ad3020e33d63a022c83989e4fb4bd16fae775a6ee125dcf8feb5d67b3e571ebd95c869f5bcf5390c7b3b749a0
|
|
7
|
+
data.tar.gz: af09f689814fbd7ea78a4323025522447b7edb9811a257973efaf083f45fa78f4c55945ccc8384e3fadd7e0b20786e7bf499fdc3d88a8bfa91cd1a4a1b28a9c3
|
data/lib/docs/generate.rb
CHANGED
|
@@ -18,11 +18,7 @@ def format_facts(fact_hash)
|
|
|
18
18
|
facts: fact_hash
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
erb =
|
|
22
|
-
ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
|
|
23
|
-
else
|
|
24
|
-
ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-')
|
|
25
|
-
end
|
|
21
|
+
erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
|
|
26
22
|
erb.result(scope.instance_eval { binding })
|
|
27
23
|
end
|
|
28
24
|
|
|
@@ -109,7 +109,7 @@ module Facter
|
|
|
109
109
|
# @api private
|
|
110
110
|
def evaluate(&block)
|
|
111
111
|
if @last_evaluated
|
|
112
|
-
msg =
|
|
112
|
+
msg = "Already evaluated #{@name}"
|
|
113
113
|
msg << " at #{@last_evaluated}" if msg.is_a? String
|
|
114
114
|
msg << ', reevaluating anyways'
|
|
115
115
|
log.warn msg
|
|
@@ -252,9 +252,7 @@ module Facter
|
|
|
252
252
|
LegacyFacter::Util::Values.deep_merge(result, current)
|
|
253
253
|
end
|
|
254
254
|
rescue LegacyFacter::Util::Values::DeepMergeError => e
|
|
255
|
-
raise ArgumentError,
|
|
256
|
-
"#{e.message}), ensure that chunks return either an Array or Hash or " \
|
|
257
|
-
'override the aggregate block', e.backtrace
|
|
255
|
+
raise ArgumentError, "Could not deep merge all chunks (Original error: #{e.message}), ensure that chunks return either an Array or Hash or override the aggregate block", e.backtrace
|
|
258
256
|
end
|
|
259
257
|
|
|
260
258
|
# Order chunks based on their dependencies
|
|
@@ -8,6 +8,7 @@ module Facter
|
|
|
8
8
|
class Base
|
|
9
9
|
STDERR_MESSAGE = 'Command %s completed with the following stderr message: %s'
|
|
10
10
|
VALID_OPTIONS = %i[on_fail expand logger timeout].freeze
|
|
11
|
+
DEPRECATED_TIMEOUT_OPTIONS = %i[time_limit limit].freeze
|
|
11
12
|
DEFAULT_EXECUTION_TIMEOUT = 300
|
|
12
13
|
def initialize
|
|
13
14
|
@log = Log.new(self)
|
|
@@ -19,7 +20,7 @@ module Facter
|
|
|
19
20
|
old = {}
|
|
20
21
|
values.each do |var, value|
|
|
21
22
|
# save the old value if it exists
|
|
22
|
-
if (old_val = ENV
|
|
23
|
+
if (old_val = ENV.fetch(var, nil))
|
|
23
24
|
old[var] = old_val
|
|
24
25
|
end
|
|
25
26
|
# set the new (temporary) value for the environment variable
|
|
@@ -43,7 +44,7 @@ module Facter
|
|
|
43
44
|
def execute(command, options = {})
|
|
44
45
|
on_fail, expand, logger, timeout = extract_options(options)
|
|
45
46
|
|
|
46
|
-
expanded_command = if !expand && builtin_command?(command) || logger
|
|
47
|
+
expanded_command = if (!expand && builtin_command?(command)) || logger
|
|
47
48
|
command
|
|
48
49
|
else
|
|
49
50
|
expand_command(command)
|
|
@@ -115,12 +116,15 @@ module Facter
|
|
|
115
116
|
expand = options.fetch(:expand, true)
|
|
116
117
|
logger = options[:logger]
|
|
117
118
|
timeout = (options[:timeout] || options[:time_limit] || options[:limit]).to_i
|
|
118
|
-
timeout = timeout.positive?
|
|
119
|
+
timeout = nil unless timeout.positive?
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
(options.keys & DEPRECATED_TIMEOUT_OPTIONS).each do |key|
|
|
122
|
+
@log.warnonce("#{key} is deprecated and will be removed in a future version, use timeout instead")
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
extra_keys = options.keys - VALID_OPTIONS - DEPRECATED_TIMEOUT_OPTIONS
|
|
121
126
|
unless extra_keys.empty?
|
|
122
|
-
@log.warn("Unexpected key passed to Facter::Core::Execution.execute option: #{extra_keys.join(',')}"
|
|
123
|
-
" - valid keys: #{VALID_OPTIONS.join(',')}")
|
|
127
|
+
@log.warn("Unexpected key passed to Facter::Core::Execution.execute option: #{extra_keys.join(',')} - valid keys: #{VALID_OPTIONS.join(',')}")
|
|
124
128
|
end
|
|
125
129
|
|
|
126
130
|
[on_fail, expand, logger, timeout]
|
|
@@ -4,7 +4,7 @@ module Facter
|
|
|
4
4
|
module Core
|
|
5
5
|
module Execution
|
|
6
6
|
class Posix < Facter::Core::Execution::Base
|
|
7
|
-
DEFAULT_SEARCH_PATHS = ['/sbin', '/usr/sbin'].freeze
|
|
7
|
+
DEFAULT_SEARCH_PATHS = ['/sbin', '/usr/sbin', '/opt/puppetlabs/bin'].freeze
|
|
8
8
|
|
|
9
9
|
def search_paths
|
|
10
10
|
# Make sure custom_facts is usable even for non-root users. Most commands
|
|
@@ -25,14 +25,14 @@ module Facter
|
|
|
25
25
|
nil
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
ABSOLUTE_PATH_REGEX = %r{^/}
|
|
28
|
+
ABSOLUTE_PATH_REGEX = %r{^/}
|
|
29
29
|
|
|
30
30
|
def absolute_path?(path)
|
|
31
31
|
!!(path =~ ABSOLUTE_PATH_REGEX)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
DOUBLE_QUOTED_COMMAND = /\A"(.+?)"(?:\s+(.*))
|
|
35
|
-
SINGLE_QUOTED_COMMAND = /\A'(.+?)'(?:\s+(.*))
|
|
34
|
+
DOUBLE_QUOTED_COMMAND = /\A"(.+?)"(?:\s+(.*))?/
|
|
35
|
+
SINGLE_QUOTED_COMMAND = /\A'(.+?)'(?:\s+(.*))?/
|
|
36
36
|
|
|
37
37
|
def expand_command(command)
|
|
38
38
|
exe = nil
|
|
@@ -48,7 +48,7 @@ module Facter
|
|
|
48
48
|
return unless exe && (expanded = which(exe))
|
|
49
49
|
|
|
50
50
|
expanded = expanded.dup
|
|
51
|
-
expanded =
|
|
51
|
+
expanded = "'#{expanded}'" if /\s/.match?(expanded)
|
|
52
52
|
expanded << " #{args}" if args
|
|
53
53
|
|
|
54
54
|
expanded
|
|
@@ -22,7 +22,7 @@ module Facter
|
|
|
22
22
|
dest = File.join(dir, bin)
|
|
23
23
|
dest.gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
|
|
24
24
|
if File.extname(dest).empty?
|
|
25
|
-
exts = ENV['PATHEXT']
|
|
25
|
+
exts = ENV['PATHEXT'] # rubocop:disable Style/FetchEnvVar
|
|
26
26
|
exts = exts ? exts.split(File::PATH_SEPARATOR) : DEFAULT_COMMAND_EXTENSIONS
|
|
27
27
|
exts.each do |ext|
|
|
28
28
|
destext = dest + ext
|
|
@@ -38,13 +38,13 @@ module Facter
|
|
|
38
38
|
slash = '[\\\\/]'
|
|
39
39
|
name = '[^\\\\/]+'
|
|
40
40
|
ABSOLUTE_PATH_REGEX =
|
|
41
|
-
/^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))/i
|
|
41
|
+
/^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))/i
|
|
42
42
|
|
|
43
43
|
def absolute_path?(path)
|
|
44
44
|
!!(path =~ ABSOLUTE_PATH_REGEX)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
DOUBLE_QUOTED_COMMAND = /\A"(.+?)"(?:\s+(.*))
|
|
47
|
+
DOUBLE_QUOTED_COMMAND = /\A"(.+?)"(?:\s+(.*))?/
|
|
48
48
|
|
|
49
49
|
def expand_command(command)
|
|
50
50
|
exe = nil
|
|
@@ -59,7 +59,7 @@ module Facter
|
|
|
59
59
|
return unless exe && (expanded = which(exe))
|
|
60
60
|
|
|
61
61
|
expanded = expanded.dup
|
|
62
|
-
expanded =
|
|
62
|
+
expanded = "\"#{expanded}\"" if /\s+/.match?(expanded)
|
|
63
63
|
expanded << " #{args}" if args
|
|
64
64
|
|
|
65
65
|
expanded
|
|
@@ -69,7 +69,7 @@ module Facter
|
|
|
69
69
|
expand = options.fetch(:expand, true)
|
|
70
70
|
raise ArgumentError.new, 'Unsupported argument on Windows expand with value false' unless expand
|
|
71
71
|
|
|
72
|
-
super
|
|
72
|
+
super
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -94,9 +94,11 @@ module Facter
|
|
|
94
94
|
# @return [String/nil] Output of the program, or nil if the command does
|
|
95
95
|
# not exist or could not be executed.
|
|
96
96
|
#
|
|
97
|
-
# @deprecated Use
|
|
97
|
+
# @deprecated Use {execute} instead
|
|
98
98
|
# @api public
|
|
99
99
|
def exec(command)
|
|
100
|
+
Facter.warnonce('Facter::Core::Execution.exec is deprecated and will be removed in a future major version. ' \
|
|
101
|
+
'Use Facter::Core::Execution.execute instead.')
|
|
100
102
|
@@impl.execute(command, on_fail: nil)
|
|
101
103
|
end
|
|
102
104
|
|
|
@@ -20,11 +20,9 @@ module LegacyFacter
|
|
|
20
20
|
# Return the timeout period for resolving a value.
|
|
21
21
|
# (see #timeout)
|
|
22
22
|
# @return [Numeric]
|
|
23
|
-
# @
|
|
24
|
-
# defined which delegates to Timeout.timeout. This method may potentially
|
|
25
|
-
# overwrite the #timeout attr_reader on this class, so we define #limit to
|
|
26
|
-
# avoid conflicts.
|
|
23
|
+
# @deprecated Use timeout instead.
|
|
27
24
|
def limit
|
|
25
|
+
Facter::Log.new(self).warnonce('limit is deprecated and will be removed in a future version, use timeout instead')
|
|
28
26
|
@timeout || 0
|
|
29
27
|
end
|
|
30
28
|
|
|
@@ -74,14 +72,14 @@ module LegacyFacter
|
|
|
74
72
|
result = nil
|
|
75
73
|
|
|
76
74
|
with_timing do
|
|
77
|
-
Timeout.timeout(
|
|
75
|
+
Timeout.timeout(@timeout || 0) do
|
|
78
76
|
result = resolve_value
|
|
79
77
|
end
|
|
80
78
|
end
|
|
81
79
|
|
|
82
80
|
LegacyFacter::Util::Normalization.normalize(result)
|
|
83
81
|
rescue Timeout::Error => e
|
|
84
|
-
Facter.log_exception(e, "Timed out after #{
|
|
82
|
+
Facter.log_exception(e, "Timed out after #{@timeout || 0} seconds while resolving #{qualified_name}")
|
|
85
83
|
|
|
86
84
|
nil
|
|
87
85
|
rescue LegacyFacter::Util::Normalization::NormalizationError => e
|
|
@@ -25,7 +25,7 @@ module LegacyFacter
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def self.windows_data_dir
|
|
28
|
-
ENV['ProgramData'] || ENV
|
|
28
|
+
ENV['ProgramData'] || ENV.fetch('APPDATA', nil) if LegacyFacter::Util::Config.windows?
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def self.external_facts_dirs
|
|
@@ -64,8 +64,7 @@ module LegacyFacter
|
|
|
64
64
|
next if file_blocked?(basename)
|
|
65
65
|
|
|
66
66
|
if facts.find { |f| f.name == basename } && cm.fact_cache_enabled?(basename)
|
|
67
|
-
Facter.log_exception(Exception.new("Caching is enabled for group \"#{basename}\" while "
|
|
68
|
-
'there are at least two external facts files with the same filename'))
|
|
67
|
+
Facter.log_exception(Exception.new("Caching is enabled for group \"#{basename}\" while there are at least two external facts files with the same filename"))
|
|
69
68
|
else
|
|
70
69
|
searched_fact = Facter::SearchedFact.new(basename, nil, nil, :file)
|
|
71
70
|
searched_fact.file = file
|
|
@@ -93,10 +92,7 @@ module LegacyFacter
|
|
|
93
92
|
if data == false
|
|
94
93
|
log.warn "Could not interpret fact file #{fact.file}"
|
|
95
94
|
elsif (data == {}) || data.nil?
|
|
96
|
-
log.debug(
|
|
97
|
-
"Structured data fact file #{fact.file} was parsed but was either empty or an invalid filetype "\
|
|
98
|
-
'(valid filetypes are .yaml, .json, and .txt).'
|
|
99
|
-
)
|
|
95
|
+
log.debug("Structured data fact file #{fact.file} was parsed but was either empty or an invalid filetype (valid filetypes are .yaml, .json, and .txt).")
|
|
100
96
|
elsif !data.is_a?(Hash)
|
|
101
97
|
log.error("Structured data fact file #{fact.file} was parsed but no key=>value data was returned.")
|
|
102
98
|
else
|
|
@@ -17,10 +17,6 @@ module Facter
|
|
|
17
17
|
# @return [String]
|
|
18
18
|
attr_reader :name
|
|
19
19
|
|
|
20
|
-
# @return [String]
|
|
21
|
-
# @deprecated
|
|
22
|
-
attr_accessor :ldapname
|
|
23
|
-
|
|
24
20
|
# Fact options e.g. fact_type
|
|
25
21
|
attr_accessor :options
|
|
26
22
|
|
|
@@ -31,16 +27,12 @@ module Facter
|
|
|
31
27
|
# for the public API for creating facts.
|
|
32
28
|
# @param name [String] the fact name
|
|
33
29
|
# @param options [Hash] optional parameters
|
|
34
|
-
# @option options [String] :ldapname set the ldapname property on the fact
|
|
35
30
|
#
|
|
36
31
|
# @api private
|
|
37
32
|
def initialize(name, options = {})
|
|
38
33
|
@name = LegacyFacter::Util::Normalization.normalize(name.to_s.downcase).intern
|
|
39
34
|
|
|
40
35
|
@options = options.dup
|
|
41
|
-
extract_ldapname_option!(options)
|
|
42
|
-
|
|
43
|
-
@ldapname ||= @name.to_s
|
|
44
36
|
|
|
45
37
|
@resolves = []
|
|
46
38
|
@searching = false
|
|
@@ -142,15 +134,6 @@ module Facter
|
|
|
142
134
|
@value
|
|
143
135
|
end
|
|
144
136
|
|
|
145
|
-
# @api private
|
|
146
|
-
# @deprecated
|
|
147
|
-
def extract_ldapname_option!(options)
|
|
148
|
-
return unless options[:ldapname]
|
|
149
|
-
|
|
150
|
-
log.warnonce('ldapname is deprecated and will be removed in a future version')
|
|
151
|
-
self.ldapname = options.delete(:ldapname)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
137
|
private
|
|
155
138
|
|
|
156
139
|
def log
|
|
@@ -244,8 +227,7 @@ module Facter
|
|
|
244
227
|
|
|
245
228
|
if resolve
|
|
246
229
|
if resolution_type != resolve.resolution_type
|
|
247
|
-
raise ArgumentError, "Cannot return resolution #{resolution_name} with type"
|
|
248
|
-
" #{resolution_type}; already defined as #{resolve.resolution_type}"
|
|
230
|
+
raise ArgumentError, "Cannot return resolution #{resolution_name} with type #{resolution_type}; already defined as #{resolve.resolution_type}"
|
|
249
231
|
end
|
|
250
232
|
else
|
|
251
233
|
case resolution_type
|
|
@@ -254,8 +236,7 @@ module Facter
|
|
|
254
236
|
when :aggregate
|
|
255
237
|
resolve = Facter::Core::Aggregate.new(resolution_name, self)
|
|
256
238
|
else
|
|
257
|
-
raise ArgumentError,
|
|
258
|
-
"Expected resolution type to be one of (:simple, :aggregate) but was #{resolution_type}"
|
|
239
|
+
raise ArgumentError, "Expected resolution type to be one of (:simple, :aggregate) but was #{resolution_type}"
|
|
259
240
|
end
|
|
260
241
|
|
|
261
242
|
@resolves << resolve
|
|
@@ -111,7 +111,7 @@ module LegacyFacter
|
|
|
111
111
|
# https://github.com/ruby/psych/blob/d2deaa9adfc88fc0b870df022a434d6431277d08/lib/psych/scalar_scanner.rb#L9
|
|
112
112
|
# It is used to detect Time in YAML, but we use it to wrap time objects in quotes to be treated as strings.
|
|
113
113
|
TIME =
|
|
114
|
-
/(\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?\s*$)
|
|
114
|
+
/(\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?\s*$)/
|
|
115
115
|
|
|
116
116
|
class YamlParser < Base
|
|
117
117
|
def parse_results
|
|
@@ -189,10 +189,10 @@ module LegacyFacter
|
|
|
189
189
|
# Returns a hash of facts from powershell output
|
|
190
190
|
def parse_results
|
|
191
191
|
powershell =
|
|
192
|
-
if File.readable?("#{ENV
|
|
193
|
-
"#{ENV
|
|
194
|
-
elsif File.readable?("#{ENV
|
|
195
|
-
"#{ENV
|
|
192
|
+
if File.readable?("#{ENV.fetch('SYSTEMROOT', nil)}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
|
|
193
|
+
"#{ENV.fetch('SYSTEMROOT', nil)}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
|
|
194
|
+
elsif File.readable?("#{ENV.fetch('SYSTEMROOT', nil)}\\system32\\WindowsPowershell\\v1.0\\powershell.exe")
|
|
195
|
+
"#{ENV.fetch('SYSTEMROOT', nil)}\\system32\\WindowsPowershell\\v1.0\\powershell.exe"
|
|
196
196
|
else
|
|
197
197
|
'powershell.exe'
|
|
198
198
|
end
|
|
@@ -23,14 +23,21 @@ module Facter
|
|
|
23
23
|
extend Facter::Core::Execution
|
|
24
24
|
|
|
25
25
|
class << self
|
|
26
|
-
#
|
|
27
|
-
# Facter::Core::Execution from Facter::Util::Resolution in Facter 2.0.0 for
|
|
28
|
-
# compatibility.
|
|
29
|
-
#
|
|
30
|
-
# @deprecated
|
|
31
|
-
#
|
|
26
|
+
# @deprecated Use Facter::Core::Execution.which instead
|
|
32
27
|
# @api public
|
|
33
|
-
|
|
28
|
+
def which(bin)
|
|
29
|
+
Facter.warnonce('Facter::Util::Resolution.which is deprecated and will be removed in a future major version. ' \
|
|
30
|
+
'Use Facter::Core::Execution.which instead.')
|
|
31
|
+
Facter::Core::Execution.which(bin)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @deprecated Use Facter::Core::Execution.execute instead
|
|
35
|
+
# @api public
|
|
36
|
+
def exec(command)
|
|
37
|
+
Facter.warnonce('Facter::Util::Resolution.exec is deprecated and will be removed in a future major version. ' \
|
|
38
|
+
'Use Facter::Core::Execution.execute instead.')
|
|
39
|
+
Facter::Core::Execution.execute(command, on_fail: nil)
|
|
40
|
+
end
|
|
34
41
|
|
|
35
42
|
# @api private
|
|
36
43
|
public :with_env
|
|
@@ -90,7 +97,7 @@ module Facter
|
|
|
90
97
|
# @api private
|
|
91
98
|
def evaluate(&block)
|
|
92
99
|
if @last_evaluated
|
|
93
|
-
msg =
|
|
100
|
+
msg = "Already evaluated #{@name}"
|
|
94
101
|
msg << " at #{@last_evaluated}" if msg.is_a? String
|
|
95
102
|
msg << ', reevaluating anyways'
|
|
96
103
|
log.warn msg
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
|
8
8
|
|
|
9
9
|
def call_the_resolver
|
|
10
10
|
fact_value = Facter::Resolvers::Aix::Networking.resolve(:interfaces)
|
|
11
|
-
fact_value = fact_value&.any?
|
|
11
|
+
fact_value = nil unless fact_value&.any?
|
|
12
12
|
|
|
13
13
|
Facter::ResolvedFact.new(FACT_NAME, fact_value)
|
|
14
14
|
end
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:userdata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Az.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
|
8
8
|
|
|
9
9
|
def call_the_resolver
|
|
10
10
|
fact_value = construct_addresses_hash
|
|
11
|
-
fact_value = !fact_value || fact_value.empty?
|
|
11
|
+
fact_value = nil if !fact_value || fact_value.empty?
|
|
12
12
|
Facter::ResolvedFact.new(FACT_NAME, fact_value, :legacy)
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:userdata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
|
8
8
|
|
|
9
9
|
def call_the_resolver
|
|
10
10
|
fact_value = construct_addresses_hash
|
|
11
|
-
fact_value = !fact_value || fact_value.empty?
|
|
11
|
+
fact_value = nil if !fact_value || fact_value.empty?
|
|
12
12
|
Facter::ResolvedFact.new(FACT_NAME, fact_value, :legacy)
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:userdata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
|
8
8
|
|
|
9
9
|
def call_the_resolver
|
|
10
10
|
fact_value = construct_addresses_hash
|
|
11
|
-
fact_value = !fact_value || fact_value.empty?
|
|
11
|
+
fact_value = nil if !fact_value || fact_value.empty?
|
|
12
12
|
Facter::ResolvedFact.new(FACT_NAME, fact_value, :legacy)
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Az.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -8,7 +8,7 @@ module Facts
|
|
|
8
8
|
|
|
9
9
|
def call_the_resolver
|
|
10
10
|
fact_value = construct_addresses_hash
|
|
11
|
-
fact_value = !fact_value || fact_value.empty?
|
|
11
|
+
fact_value = nil if !fact_value || fact_value.empty?
|
|
12
12
|
Facter::ResolvedFact.new(FACT_NAME, fact_value, :legacy)
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:metadata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -10,7 +10,7 @@ module Facts
|
|
|
10
10
|
|
|
11
11
|
fact_value = Facter::Resolvers::Ec2.resolve(:userdata)
|
|
12
12
|
|
|
13
|
-
Facter::ResolvedFact.new(FACT_NAME, fact_value
|
|
13
|
+
Facter::ResolvedFact.new(FACT_NAME, fact_value && fact_value.empty? ? nil : fact_value)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -113,7 +113,7 @@ module Facter
|
|
|
113
113
|
negate_options = %w[block cache custom_facts external_facts]
|
|
114
114
|
|
|
115
115
|
template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb')
|
|
116
|
-
erb = ERB.new(File.read(template),
|
|
116
|
+
erb = ERB.new(File.read(template), trim_mode: '-')
|
|
117
117
|
erb.filename = template
|
|
118
118
|
puts erb.result(binding)
|
|
119
119
|
end
|
|
@@ -201,11 +201,11 @@ module Facter
|
|
|
201
201
|
Cli.commands.values
|
|
202
202
|
.select { |command_class| command_class.instance_of?(Thor::Command) }
|
|
203
203
|
.each do |command|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
help_command_options << build_option(
|
|
205
|
+
command['name'],
|
|
206
|
+
[command['usage'].split(',')[1]],
|
|
207
|
+
command['description']
|
|
208
|
+
)
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
help_command_options
|
|
@@ -77,8 +77,7 @@ module Facter
|
|
|
77
77
|
|
|
78
78
|
def external_fact_in_custom_group?(searched_fact, fact_name, fact)
|
|
79
79
|
if searched_fact.type == :file && fact[:group] != fact_name
|
|
80
|
-
@log.error("Cannot cache '#{fact_name}' fact from '#{fact[:group]}' group. "
|
|
81
|
-
'Caching custom group is not supported for external facts.')
|
|
80
|
+
@log.error("Cannot cache '#{fact_name}' fact from '#{fact[:group]}' group. Caching custom group is not supported for external facts.")
|
|
82
81
|
return true
|
|
83
82
|
end
|
|
84
83
|
|
|
@@ -121,8 +120,7 @@ cache_format_version is incorrect!")
|
|
|
121
120
|
else
|
|
122
121
|
return unless data[searched_fact.name]
|
|
123
122
|
|
|
124
|
-
[Facter::ResolvedFact.new(searched_fact.name, data[searched_fact.name], searched_fact.type,
|
|
125
|
-
searched_fact.user_query)]
|
|
123
|
+
[Facter::ResolvedFact.new(searched_fact.name, data[searched_fact.name], searched_fact.type, searched_fact.user_query)]
|
|
126
124
|
end
|
|
127
125
|
end
|
|
128
126
|
|
|
@@ -131,8 +129,7 @@ cache_format_version is incorrect!")
|
|
|
131
129
|
data.each do |fact_name, fact_value|
|
|
132
130
|
next if fact_name == 'cache_format_version'
|
|
133
131
|
|
|
134
|
-
fact = Facter::ResolvedFact.new(fact_name, fact_value, searched_fact.type,
|
|
135
|
-
searched_fact.user_query)
|
|
132
|
+
fact = Facter::ResolvedFact.new(fact_name, fact_value, searched_fact.type, searched_fact.user_query)
|
|
136
133
|
fact.file = searched_fact.file
|
|
137
134
|
facts << fact
|
|
138
135
|
end
|
|
@@ -79,9 +79,7 @@ module Facter
|
|
|
79
79
|
split_fact_name = extract_fact_name(fact)
|
|
80
80
|
bury(*split_fact_name << fact.value)
|
|
81
81
|
rescue NoMethodError
|
|
82
|
-
@log.error("#{fact.type.to_s.capitalize} fact `#{fact.name}` cannot be added to collection."
|
|
83
|
-
' The format of this fact is incompatible with other'\
|
|
84
|
-
" facts that belong to `#{fact.name.split('.').first}` group")
|
|
82
|
+
@log.error("#{fact.type.to_s.capitalize} fact `#{fact.name}` cannot be added to collection. The format of this fact is incompatible with other facts that belong to `#{fact.name.split('.').first}` group")
|
|
85
83
|
end
|
|
86
84
|
|
|
87
85
|
def extract_fact_name(fact)
|