facter 4.2.1 → 4.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -0
- data/lib/facter/custom_facts/core/execution/base.rb +14 -9
- data/lib/facter/custom_facts/core/execution.rb +25 -17
- data/lib/facter/custom_facts/core/file_loader.rb +0 -1
- data/lib/facter/custom_facts/core/legacy_facter.rb +0 -2
- data/lib/facter/custom_facts/core/resolvable.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +6 -4
- data/lib/facter/custom_facts/util/confine.rb +9 -3
- data/lib/facter/custom_facts/util/directory_loader.rb +18 -6
- data/lib/facter/custom_facts/util/fact.rb +12 -10
- data/lib/facter/custom_facts/util/loader.rb +7 -3
- data/lib/facter/custom_facts/util/parser.rb +8 -2
- data/lib/facter/custom_facts/util/resolution.rb +5 -1
- data/lib/facter/facts/windows/os/windows/display_version.rb +19 -0
- data/lib/facter/framework/cli/cli.rb +4 -0
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +0 -2
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +0 -1
- data/lib/facter/framework/core/fact_manager.rb +14 -1
- data/lib/facter/framework/core/options/option_store.rb +3 -1
- data/lib/facter/framework/logging/logger.rb +61 -0
- data/lib/facter/framework/parsers/query_parser.rb +1 -4
- data/lib/facter/models/resolved_fact.rb +4 -0
- data/lib/facter/resolvers/aix/disks.rb +1 -1
- data/lib/facter/resolvers/aix/mountpoints.rb +1 -1
- data/lib/facter/resolvers/aix/partitions.rb +1 -1
- data/lib/facter/resolvers/aix/processors.rb +2 -1
- data/lib/facter/resolvers/linux/networking.rb +0 -1
- data/lib/facter/resolvers/lsb_release.rb +1 -2
- data/lib/facter/resolvers/macosx/{processor.rb → processors.rb} +21 -21
- data/lib/facter/resolvers/networking.rb +3 -1
- data/lib/facter/resolvers/os_release.rb +7 -4
- data/lib/facter/resolvers/partitions.rb +1 -3
- data/lib/facter/resolvers/windows/product_release.rb +13 -4
- data/lib/facter/util/aix/info_extractor.rb +60 -9
- data/lib/facter/util/facts/windows_release_finder.rb +4 -2
- data/lib/facter/util/linux/dhcp.rb +4 -1
- data/lib/facter/util/linux/socket_parser.rb +17 -2
- data/lib/facter/util/resolvers/http.rb +3 -0
- data/lib/facter/version.rb +1 -1
- data/lib/facter.rb +31 -18
- metadata +12 -5
- data/lib/facter/custom_facts/core/logging.rb +0 -203
data/lib/facter.rb
CHANGED
@@ -13,8 +13,6 @@ module Facter
|
|
13
13
|
Options.init
|
14
14
|
Log.output(STDOUT)
|
15
15
|
@already_searched = {}
|
16
|
-
@debug_once = []
|
17
|
-
@warn_once = []
|
18
16
|
|
19
17
|
class << self
|
20
18
|
# Method used by puppet-agent to retrieve facts
|
@@ -109,8 +107,7 @@ module Facter
|
|
109
107
|
# @api public
|
110
108
|
def clear
|
111
109
|
@already_searched = {}
|
112
|
-
|
113
|
-
@warn_once = []
|
110
|
+
Facter.clear_messages
|
114
111
|
LegacyFacter.clear
|
115
112
|
Options[:custom_dir] = []
|
116
113
|
LegacyFacter.collection.invalidate_custom_facts
|
@@ -119,6 +116,13 @@ module Facter
|
|
119
116
|
nil
|
120
117
|
end
|
121
118
|
|
119
|
+
# Clears the seen state of debug and warning messages.
|
120
|
+
#
|
121
|
+
# @return [nil]
|
122
|
+
def clear_messages
|
123
|
+
Facter::Log.clear_messages
|
124
|
+
end
|
125
|
+
|
122
126
|
# Retrieves the value of a core fact. External or custom facts are
|
123
127
|
# not returned with this call. Returns `nil` if no such fact exists.
|
124
128
|
#
|
@@ -153,13 +157,7 @@ module Facter
|
|
153
157
|
#
|
154
158
|
# @api public
|
155
159
|
def debugonce(message)
|
156
|
-
|
157
|
-
|
158
|
-
message_string = message.to_s
|
159
|
-
return if @debug_once.include? message_string
|
160
|
-
|
161
|
-
@debug_once << message_string
|
162
|
-
logger.debug(message_string)
|
160
|
+
logger.debugonce(message)
|
163
161
|
nil
|
164
162
|
end
|
165
163
|
|
@@ -207,6 +205,25 @@ module Facter
|
|
207
205
|
Facter::Options[:debug] = debug_bool
|
208
206
|
end
|
209
207
|
|
208
|
+
# Check whether http debugging is enabled
|
209
|
+
#
|
210
|
+
# @return [bool]
|
211
|
+
#
|
212
|
+
# @api public
|
213
|
+
def http_debug?
|
214
|
+
Options[:http_debug]
|
215
|
+
end
|
216
|
+
|
217
|
+
# Enable or disable http debugging
|
218
|
+
# @param debug_bool [bool] State which http debugging should have
|
219
|
+
#
|
220
|
+
# @return [type] [description]
|
221
|
+
#
|
222
|
+
# @api public
|
223
|
+
def http_debug(http_debug_bool)
|
224
|
+
Facter::Options[:http_debug] = http_debug_bool
|
225
|
+
end
|
226
|
+
|
210
227
|
# Enable sequential resolving of facts
|
211
228
|
#
|
212
229
|
# @return [bool]
|
@@ -392,7 +409,7 @@ module Facter
|
|
392
409
|
#
|
393
410
|
# @api public
|
394
411
|
def value(user_query)
|
395
|
-
user_query = user_query.to_s
|
412
|
+
user_query = user_query.to_s.downcase
|
396
413
|
resolve_fact(user_query)
|
397
414
|
|
398
415
|
@already_searched[user_query]&.value
|
@@ -409,7 +426,7 @@ module Facter
|
|
409
426
|
#
|
410
427
|
# @api public
|
411
428
|
def fact(user_query)
|
412
|
-
user_query = user_query.to_s
|
429
|
+
user_query = user_query.to_s.downcase
|
413
430
|
resolve_fact(user_query)
|
414
431
|
|
415
432
|
@already_searched[user_query]
|
@@ -482,11 +499,7 @@ module Facter
|
|
482
499
|
#
|
483
500
|
# @api public
|
484
501
|
def warnonce(message)
|
485
|
-
|
486
|
-
return if @warn_once.include? message_string
|
487
|
-
|
488
|
-
@warn_once << message_string
|
489
|
-
logger.warn(message_string)
|
502
|
+
logger.warnonce(message)
|
490
503
|
nil
|
491
504
|
end
|
492
505
|
|
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '12.3'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 12.3.3
|
@@ -21,6 +24,9 @@ dependencies:
|
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '12.3'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 12.3.3
|
@@ -192,6 +198,7 @@ executables:
|
|
192
198
|
extensions: []
|
193
199
|
extra_rdoc_files: []
|
194
200
|
files:
|
201
|
+
- LICENSE
|
195
202
|
- bin/facter
|
196
203
|
- lib/docs/generate.rb
|
197
204
|
- lib/docs/generate_cli.rb
|
@@ -207,7 +214,6 @@ files:
|
|
207
214
|
- lib/facter/custom_facts/core/execution/windows.rb
|
208
215
|
- lib/facter/custom_facts/core/file_loader.rb
|
209
216
|
- lib/facter/custom_facts/core/legacy_facter.rb
|
210
|
-
- lib/facter/custom_facts/core/logging.rb
|
211
217
|
- lib/facter/custom_facts/core/resolvable.rb
|
212
218
|
- lib/facter/custom_facts/core/suitable.rb
|
213
219
|
- lib/facter/custom_facts/util/collection.rb
|
@@ -840,6 +846,7 @@ files:
|
|
840
846
|
- lib/facter/facts/windows/os/hardware.rb
|
841
847
|
- lib/facter/facts/windows/os/name.rb
|
842
848
|
- lib/facter/facts/windows/os/release.rb
|
849
|
+
- lib/facter/facts/windows/os/windows/display_version.rb
|
843
850
|
- lib/facter/facts/windows/os/windows/edition_id.rb
|
844
851
|
- lib/facter/facts/windows/os/windows/installation_type.rb
|
845
852
|
- lib/facter/facts/windows/os/windows/product_name.rb
|
@@ -958,7 +965,7 @@ files:
|
|
958
965
|
- lib/facter/resolvers/macosx/filesystems.rb
|
959
966
|
- lib/facter/resolvers/macosx/load_averages.rb
|
960
967
|
- lib/facter/resolvers/macosx/mountpoints.rb
|
961
|
-
- lib/facter/resolvers/macosx/
|
968
|
+
- lib/facter/resolvers/macosx/processors.rb
|
962
969
|
- lib/facter/resolvers/macosx/swap_memory.rb
|
963
970
|
- lib/facter/resolvers/macosx/system_memory.rb
|
964
971
|
- lib/facter/resolvers/macosx/system_profiler.rb
|
@@ -1065,7 +1072,7 @@ files:
|
|
1065
1072
|
- lib/facter/version.rb
|
1066
1073
|
homepage: https://github.com/puppetlabs/facter
|
1067
1074
|
licenses:
|
1068
|
-
-
|
1075
|
+
- Apache-2.0
|
1069
1076
|
metadata: {}
|
1070
1077
|
post_install_message:
|
1071
1078
|
rdoc_options: []
|
@@ -1,203 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module LegacyFacter
|
4
|
-
module Core
|
5
|
-
module Logging
|
6
|
-
extend self
|
7
|
-
|
8
|
-
# @api private
|
9
|
-
GREEN = "\e[0;32m"
|
10
|
-
# @api private
|
11
|
-
RESET = "\e[0m"
|
12
|
-
|
13
|
-
RED = "\e[31m"
|
14
|
-
|
15
|
-
# @api private
|
16
|
-
@@debug = false
|
17
|
-
# @api private
|
18
|
-
@@timing = false
|
19
|
-
# @api private
|
20
|
-
@@trace = false
|
21
|
-
|
22
|
-
# @api private
|
23
|
-
@@warn_messages = {}
|
24
|
-
# @api private
|
25
|
-
@@debug_messages = {}
|
26
|
-
|
27
|
-
# @api private
|
28
|
-
@@message_callback = nil
|
29
|
-
|
30
|
-
# Used to register a callback that is called when a message is logged.
|
31
|
-
# If a block is given, Facter will not log messages.
|
32
|
-
# If a block is not given, Facter will resume logging messages.
|
33
|
-
# @param block [Proc] the callback to call when a message is logged.
|
34
|
-
# The first argument to the callback will be a symbol representing a level. The supported
|
35
|
-
# levels are: :trace, :debug, :info, :warn, :error, and :fatal.
|
36
|
-
# The second argument to the callback will be a string containing the message
|
37
|
-
# that was logged.
|
38
|
-
# @api public
|
39
|
-
def on_message(&block)
|
40
|
-
@@message_callback = block
|
41
|
-
end
|
42
|
-
|
43
|
-
# Prints a debug message if debugging is turned on
|
44
|
-
#
|
45
|
-
# @param msg [String] the debug message
|
46
|
-
# @return [void]
|
47
|
-
def debug(msg)
|
48
|
-
return unless debugging?
|
49
|
-
|
50
|
-
if msg.nil? || msg.empty?
|
51
|
-
invoker = caller(1..1).first.slice(/.*:\d+/)
|
52
|
-
self.warn "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
|
53
|
-
elsif @@message_callback
|
54
|
-
@@message_callback.call(:debug, msg)
|
55
|
-
else
|
56
|
-
puts GREEN + msg + RESET
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Prints a debug message only once.
|
61
|
-
#
|
62
|
-
# @note Uniqueness is based on the string, not the specific location
|
63
|
-
# of the method call.
|
64
|
-
#
|
65
|
-
# @param msg [String] the debug message
|
66
|
-
# @return [void]
|
67
|
-
def debugonce(msg)
|
68
|
-
return unless msg && !msg.empty? && @@debug_messages[msg].nil?
|
69
|
-
|
70
|
-
@@debug_messages[msg] = true
|
71
|
-
debug(msg)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Prints a warning message. The message is only printed if debugging
|
75
|
-
# is enabled.
|
76
|
-
#
|
77
|
-
# @param msg [String] the warning message to be printed
|
78
|
-
#
|
79
|
-
# @return [void]
|
80
|
-
def warn(msg)
|
81
|
-
if msg.nil? || msg.empty?
|
82
|
-
invoker = caller(1..1).first.slice(/.*:\d+/)
|
83
|
-
msg = "#{self.class}#debug invoked with invalid message #{msg.inspect}:#{msg.class} at #{invoker}"
|
84
|
-
end
|
85
|
-
if @@message_callback
|
86
|
-
@@message_callback.call(:warn, msg)
|
87
|
-
else
|
88
|
-
Kernel.warn msg
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# Prints a warning message only once per process. Each unique string
|
93
|
-
# is printed once.
|
94
|
-
#
|
95
|
-
# @note Unlike {warn} the message will be printed even if debugging is
|
96
|
-
# not turned on. This behavior is likely to change and should not be
|
97
|
-
# relied on.
|
98
|
-
#
|
99
|
-
# @param msg [String] the warning message to be printed
|
100
|
-
#
|
101
|
-
# @return [void]
|
102
|
-
def warnonce(msg)
|
103
|
-
return unless @@warn_messages[msg].nil?
|
104
|
-
|
105
|
-
self.warn(msg)
|
106
|
-
@@warn_messages[msg] = true
|
107
|
-
end
|
108
|
-
|
109
|
-
def log_exception(exception, message = :default)
|
110
|
-
self.warn(format_exception(exception, message, @@trace))
|
111
|
-
end
|
112
|
-
|
113
|
-
def format_exception(exception, message, trace)
|
114
|
-
arr = []
|
115
|
-
|
116
|
-
if message == :default
|
117
|
-
arr << exception.message
|
118
|
-
elsif message
|
119
|
-
arr << message
|
120
|
-
end
|
121
|
-
|
122
|
-
if trace
|
123
|
-
arr << 'backtrace:'
|
124
|
-
arr.concat(exception.backtrace)
|
125
|
-
end
|
126
|
-
|
127
|
-
"#{RED}#{arr.flatten.join("\n")}#{RESET}"
|
128
|
-
end
|
129
|
-
|
130
|
-
# Print an exception message, and optionally a backtrace if trace is set
|
131
|
-
|
132
|
-
# Print timing information
|
133
|
-
#
|
134
|
-
# @param string [String] the time to print
|
135
|
-
# @return [void]
|
136
|
-
#
|
137
|
-
# @api private
|
138
|
-
def show_time(string)
|
139
|
-
return unless string && timing?
|
140
|
-
|
141
|
-
if @@message_callback
|
142
|
-
@@message_callback.call(:info, string)
|
143
|
-
else
|
144
|
-
$stderr.puts "#{GREEN}#{string}#{RESET}"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# Enable or disable logging of debug messages
|
149
|
-
#
|
150
|
-
# @param bool [true, false]
|
151
|
-
# @return [void]
|
152
|
-
#
|
153
|
-
# @api private
|
154
|
-
def debugging(bool)
|
155
|
-
@@debug = bool
|
156
|
-
end
|
157
|
-
|
158
|
-
# Is debugging enabled?
|
159
|
-
#
|
160
|
-
# @return [true, false]
|
161
|
-
#
|
162
|
-
# @api private
|
163
|
-
def debugging?
|
164
|
-
@@debug
|
165
|
-
end
|
166
|
-
|
167
|
-
# Enable or disable logging of timing information
|
168
|
-
#
|
169
|
-
# @param bool [true, false]
|
170
|
-
# @return [void]
|
171
|
-
#
|
172
|
-
# @api private
|
173
|
-
def timing(bool)
|
174
|
-
@@timing = bool
|
175
|
-
end
|
176
|
-
|
177
|
-
# Returns whether timing output is turned on
|
178
|
-
#
|
179
|
-
# @api private
|
180
|
-
def timing?
|
181
|
-
@@timing
|
182
|
-
end
|
183
|
-
|
184
|
-
def trace(bool)
|
185
|
-
@@trace = bool
|
186
|
-
end
|
187
|
-
|
188
|
-
def trace?
|
189
|
-
@@trace
|
190
|
-
end
|
191
|
-
|
192
|
-
# Clears the seen state of debug and warning messages. See {debugonce} and {warnonce}.
|
193
|
-
#
|
194
|
-
# @return [void]
|
195
|
-
#
|
196
|
-
# @api private
|
197
|
-
def clear_messages
|
198
|
-
@@debug_messages.clear
|
199
|
-
@@warn_messages.clear
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|