facter 4.5.2 → 4.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/facter +1 -1
- data/lib/docs/generate.rb +1 -6
- data/lib/facter/custom_facts/core/directed_graph.rb +2 -4
- data/lib/facter/custom_facts/core/execution/base.rb +1 -1
- data/lib/facter/custom_facts/core/execution/posix.rb +6 -2
- data/lib/facter/custom_facts/core/execution/windows.rb +4 -1
- data/lib/facter/custom_facts/core/execution.rb +1 -1
- data/lib/facter/custom_facts/core/file_loader.rb +0 -4
- data/lib/facter/custom_facts/core/suitable.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +2 -4
- data/lib/facter/custom_facts/util/confine.rb +4 -1
- data/lib/facter/custom_facts/util/fact.rb +1 -1
- data/lib/facter/custom_facts/util/loader.rb +2 -2
- data/lib/facter/custom_facts/util/resolution.rb +8 -4
- data/lib/facter/custom_facts/util/values.rb +1 -1
- data/lib/facter/facts/linux/dmi/product/version.rb +19 -0
- data/lib/facter/facts/linux/kernelmajversion.rb +1 -1
- data/lib/facter/facts/macosx/is_virtual.rb +1 -1
- data/lib/facter/facts/macosx/virtual.rb +3 -3
- data/lib/facter/facts/mariner/os/release.rb +1 -1
- data/lib/facter/facts/photon/os/release.rb +1 -1
- data/lib/facter/facts/solaris/kernelmajversion.rb +1 -1
- data/lib/facter/facts/solaris/ldom.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/kvm.rb +1 -1
- data/lib/facter/facts/windows/interfaces.rb +1 -1
- data/lib/facter/framework/benchmarking/timer.rb +2 -2
- data/lib/facter/framework/cli/cli.rb +6 -8
- data/lib/facter/framework/cli/cli_launcher.rb +1 -1
- data/lib/facter/framework/config/fact_groups.rb +1 -1
- data/lib/facter/framework/core/cache_manager.rb +5 -6
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +1 -3
- data/lib/facter/framework/core/fact_manager.rb +4 -4
- data/lib/facter/framework/core/file_loader.rb +734 -733
- data/lib/facter/framework/core/options/config_file_options.rb +4 -6
- data/lib/facter/framework/formatters/hocon_fact_formatter.rb +3 -2
- data/lib/facter/framework/formatters/legacy_fact_formatter.rb +4 -4
- data/lib/facter/framework/logging/logger.rb +6 -6
- data/lib/facter/framework/logging/logger_helper.rb +10 -11
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/networking.rb +1 -1
- data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
- data/lib/facter/resolvers/amzn/os_release_rpm.rb +1 -1
- data/lib/facter/resolvers/dmi.rb +2 -1
- data/lib/facter/resolvers/fips_enabled.rb +1 -1
- data/lib/facter/resolvers/freebsd/dmi.rb +1 -1
- data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
- data/lib/facter/resolvers/freebsd/virtual.rb +1 -1
- data/lib/facter/resolvers/linux/hostname.rb +1 -1
- data/lib/facter/resolvers/macosx/dmi.rb +1 -1
- data/lib/facter/resolvers/macosx/filesystems.rb +1 -1
- data/lib/facter/resolvers/memory.rb +1 -1
- data/lib/facter/resolvers/networking.rb +3 -3
- data/lib/facter/resolvers/os_release.rb +1 -1
- data/lib/facter/resolvers/partitions.rb +2 -2
- data/lib/facter/resolvers/processors_lscpu.rb +2 -2
- data/lib/facter/resolvers/solaris/ffi/ffi.rb +2 -2
- data/lib/facter/resolvers/solaris/mountpoints.rb +1 -1
- data/lib/facter/resolvers/solaris/networking.rb +1 -1
- data/lib/facter/resolvers/solaris/os_release.rb +2 -2
- data/lib/facter/resolvers/virt_what.rb +2 -1
- data/lib/facter/resolvers/windows/memory.rb +3 -2
- data/lib/facter/resolvers/windows/product_release.rb +7 -7
- data/lib/facter/util/aix/odm_query.rb +1 -1
- data/lib/facter/util/api_debugger.rb +2 -2
- data/lib/facter/util/facts/posix/virtual_detector.rb +8 -5
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/file_helper.rb +1 -2
- data/lib/facter/util/macosx/system_profile_executor.rb +3 -3
- data/lib/facter/util/resolvers/networking/networking.rb +4 -3
- data/lib/facter/util/utils.rb +2 -2
- data/lib/facter/version.rb +1 -1
- data/lib/facter.rb +7 -0
- metadata +10 -9
@@ -60,10 +60,8 @@ module Facter
|
|
60
60
|
def augment_custom(file_global_conf)
|
61
61
|
return unless file_global_conf
|
62
62
|
|
63
|
-
if Options.cli?
|
64
|
-
|
65
|
-
@options[:no_custom_facts] = file_global_conf['no-custom-facts']
|
66
|
-
end
|
63
|
+
if Options.cli? && !file_global_conf['no-custom-facts'].nil?
|
64
|
+
@options[:no_custom_facts] = file_global_conf['no-custom-facts']
|
67
65
|
end
|
68
66
|
|
69
67
|
@options[:custom_dir] = file_global_conf['custom-dir'] unless file_global_conf['custom-dir'].nil?
|
@@ -73,8 +71,8 @@ module Facter
|
|
73
71
|
def augment_external(global_conf)
|
74
72
|
return unless global_conf
|
75
73
|
|
76
|
-
if Options.cli?
|
77
|
-
@options[:no_external_facts] = global_conf['no-external-facts']
|
74
|
+
if Options.cli? && !global_conf['no-external-facts'].nil?
|
75
|
+
@options[:no_external_facts] = global_conf['no-external-facts']
|
78
76
|
end
|
79
77
|
|
80
78
|
@options[:external_dir] = [global_conf['external-dir']].flatten unless global_conf['external-dir'].nil?
|
@@ -14,7 +14,8 @@ module Facter
|
|
14
14
|
|
15
15
|
user_query = user_queries.first
|
16
16
|
return format_for_no_query(resolved_facts) if user_query.empty?
|
17
|
-
|
17
|
+
|
18
|
+
format_for_single_user_query(user_queries.first, resolved_facts) unless user_query.empty?
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -39,7 +40,7 @@ module Facter
|
|
39
40
|
|
40
41
|
return '' unless fact_value
|
41
42
|
|
42
|
-
fact_value.
|
43
|
+
fact_value.instance_of?(Hash) ? hash_to_hocon(fact_value) : fact_value
|
43
44
|
end
|
44
45
|
|
45
46
|
def hash_to_hocon(fact_collection)
|
@@ -42,7 +42,7 @@ module Facter
|
|
42
42
|
pretty_json = handle_newlines(pretty_json)
|
43
43
|
|
44
44
|
@log.debug('Remove quotes from value if value is a string')
|
45
|
-
pretty_json.gsub(/^(\S*) =>
|
45
|
+
pretty_json.gsub(/^(\S*) => "(.*)"/, '\1 => \2')
|
46
46
|
end
|
47
47
|
|
48
48
|
def format_for_single_user_query(user_query, resolved_facts)
|
@@ -55,7 +55,7 @@ module Facter
|
|
55
55
|
pretty_json = fact_value.nil? ? '' : hash_to_facter_format(fact_value)
|
56
56
|
|
57
57
|
@log.debug('Remove quotes from value if it is a simple string')
|
58
|
-
pretty_json.gsub(/^"(.*)
|
58
|
+
pretty_json.gsub(/^"(.*)"/, '\1')
|
59
59
|
end
|
60
60
|
|
61
61
|
def hash_to_facter_format(facts_hash)
|
@@ -66,7 +66,7 @@ module Facter
|
|
66
66
|
pretty_json.gsub!(/":\s/, '" => ')
|
67
67
|
|
68
68
|
@log.debug('Remove quotes from parent nodes')
|
69
|
-
pretty_json.gsub!(
|
69
|
+
pretty_json.gsub!(/"(.*)"\ =>/, '\1 =>')
|
70
70
|
|
71
71
|
@log.debug('Remove double backslashes from paths')
|
72
72
|
pretty_json.gsub(/\\\\/, '\\')
|
@@ -95,7 +95,7 @@ module Facter
|
|
95
95
|
# quotation marks that come after \ are not removed
|
96
96
|
@log.debug('Remove unnecessary comma and quotation marks on root facts')
|
97
97
|
output.split("\n")
|
98
|
-
.map! { |line|
|
98
|
+
.map! { |line| /^\s+/.match?(line) ? line : line.gsub(/,$|(?<!\\)"/, '').gsub('\\"', '"') }.join("\n")
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -107,7 +107,7 @@ module Facter
|
|
107
107
|
@@message_callback.call(:debug, msg)
|
108
108
|
else
|
109
109
|
msg = colorize(msg, CYAN) if Options[:color]
|
110
|
-
@@logger.debug(@class_name
|
110
|
+
@@logger.debug("#{@class_name} - #{msg}")
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -128,7 +128,7 @@ module Facter
|
|
128
128
|
@@message_callback.call(:info, msg)
|
129
129
|
else
|
130
130
|
msg = colorize(msg, GREEN) if Options[:color]
|
131
|
-
@@logger.info(@class_name
|
131
|
+
@@logger.info("#{@class_name} - #{msg}")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -137,7 +137,7 @@ module Facter
|
|
137
137
|
@@message_callback.call(:warn, msg)
|
138
138
|
else
|
139
139
|
msg = colorize(msg, YELLOW) if Options[:color]
|
140
|
-
@@logger.warn(@class_name
|
140
|
+
@@logger.warn("#{@class_name} - #{msg}")
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -149,20 +149,20 @@ module Facter
|
|
149
149
|
warn(message_string)
|
150
150
|
end
|
151
151
|
|
152
|
-
def error(msg, colorize = false)
|
152
|
+
def error(msg, colorize = false) # rubocop:disable Style/OptionalBooleanParameter
|
153
153
|
@@has_errors = true
|
154
154
|
|
155
155
|
if @@message_callback && Options[:allow_external_loggers]
|
156
156
|
@@message_callback.call(:error, msg)
|
157
157
|
else
|
158
158
|
msg = colorize(msg, RED) if colorize || Options[:color]
|
159
|
-
@@logger.error(@class_name
|
159
|
+
@@logger.error("#{@class_name} - #{msg}")
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
163
|
def log_exception(exception)
|
164
164
|
msg = exception.message
|
165
|
-
msg += "\n
|
165
|
+
msg += "\n#{exception.backtrace.join("\n")}" if Options[:trace]
|
166
166
|
|
167
167
|
error(msg, true)
|
168
168
|
end
|
@@ -3,17 +3,16 @@
|
|
3
3
|
class LoggerHelper
|
4
4
|
class << self
|
5
5
|
def determine_callers_name(sender_self)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
class_name
|
6
|
+
case sender_self
|
7
|
+
when String
|
8
|
+
sender_self
|
9
|
+
when Class
|
10
|
+
sender_self.name
|
11
|
+
when Module
|
12
|
+
sender_self.name
|
13
|
+
else # when class is singleton
|
14
|
+
sender_self.class.name
|
15
|
+
end
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -47,7 +47,7 @@ module Facter
|
|
47
47
|
|
48
48
|
info = line.split("\s")
|
49
49
|
interface_name = info[0]
|
50
|
-
mac = info[3][/^([0-9a-f]{1,2}[
|
50
|
+
mac = info[3][/^([0-9a-f]{1,2}[.:-]){5}([0-9a-f]{1,2})$/]
|
51
51
|
if interfaces[interface_name]
|
52
52
|
interfaces[interface_name][:mtu] = info[1].to_i
|
53
53
|
interfaces[interface_name][:mac] = format_mac_address(mac) if mac
|
@@ -15,7 +15,7 @@ module Facter
|
|
15
15
|
|
16
16
|
def rpm_system_call(fact_name)
|
17
17
|
output = Facter::Core::Execution.execute(
|
18
|
-
'rpm -q --qf \'
|
18
|
+
'rpm -q --qf \'%<NAME>s\n%<VERSION>s\n%<RELEASE>s\n%<VENDOR>s\' -f /etc/os-release',
|
19
19
|
logger: log
|
20
20
|
)
|
21
21
|
build_fact_list(output)
|
data/lib/facter/resolvers/dmi.rb
CHANGED
@@ -22,6 +22,7 @@ module Facter
|
|
22
22
|
# :product_serial
|
23
23
|
# :product_name
|
24
24
|
# :product_uuid
|
25
|
+
# :product_version
|
25
26
|
|
26
27
|
private
|
27
28
|
|
@@ -32,7 +33,7 @@ module Facter
|
|
32
33
|
def read_facts(fact_name)
|
33
34
|
files = %w[bios_date bios_vendor bios_version board_asset_tag board_vendor board_name
|
34
35
|
board_serial chassis_asset_tag chassis_type sys_vendor product_name
|
35
|
-
product_serial product_uuid]
|
36
|
+
product_serial product_uuid product_version]
|
36
37
|
return unless File.directory?('/sys/class/dmi')
|
37
38
|
|
38
39
|
file_content = Facter::Util::FileHelper.safe_read("/sys/class/dmi/id/#{fact_name}", nil)
|
@@ -15,7 +15,7 @@ module Facter
|
|
15
15
|
|
16
16
|
def read_swap_memory(fact_name)
|
17
17
|
output = Facter::Core::Execution.execute('swapinfo -k', logger: log)
|
18
|
-
data = output.split("\n")[1
|
18
|
+
data = output.split("\n")[1..].map { |line| line.split(/\s+/) }
|
19
19
|
|
20
20
|
unless data.empty?
|
21
21
|
@fact_list[:total_bytes] = kilobytes_to_bytes(data.map { |line| line[1].to_i }.inject(:+))
|
@@ -16,7 +16,7 @@ module Facter
|
|
16
16
|
|
17
17
|
def read_filesystems(fact_name)
|
18
18
|
output = Facter::Core::Execution.execute('mount', logger: log)
|
19
|
-
filesystems = output.scan(/\(([a-z]+)
|
19
|
+
filesystems = output.scan(/\(([a-z]+),*/).flatten
|
20
20
|
@fact_list[:macosx_filesystems] = filesystems.uniq.sort.join(',')
|
21
21
|
@fact_list[fact_name]
|
22
22
|
end
|
@@ -57,7 +57,7 @@ module Facter
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def compute_capacity(used, total)
|
60
|
-
format('%<computed_capacity>.2f', computed_capacity: (used / total.to_f * 100))
|
60
|
+
"#{format('%<computed_capacity>.2f', computed_capacity: (used / total.to_f * 100))}%"
|
61
61
|
end
|
62
62
|
|
63
63
|
def compute_used(total, free)
|
@@ -39,12 +39,12 @@ module Facter
|
|
39
39
|
# convert ip ranges into single ip. eg. 10.16.132.213 --> 10.16.132.213 is converted to 10.16.132.213
|
40
40
|
# convert ip6 ranges into single ip. eg. 2001:db8:cafe::132:213 -->
|
41
41
|
# 2001:db8:cafe::132:213 is converted to 2001:db8:cafe::132:213
|
42
|
-
response.gsub!(/([\da-fA-F]+([
|
42
|
+
response.gsub!(/([\da-fA-F]+([.:]+[\da-fA-F]+)*)\s+-->\s+[\da-fA-F]+([.:]+[\da-fA-F]+)*/, '\\1')
|
43
43
|
end
|
44
44
|
|
45
45
|
def parse_interfaces_response(response)
|
46
46
|
parsed_interfaces_data = {}
|
47
|
-
interfaces_data = Hash[*response.split(/^([A-Za-z0-9_
|
47
|
+
interfaces_data = Hash[*response.split(/^([A-Za-z0-9_.]+): /)[1..]]
|
48
48
|
|
49
49
|
interfaces_data.each do |interface_name, raw_data|
|
50
50
|
parsed_interface_data = {}
|
@@ -66,7 +66,7 @@ module Facter
|
|
66
66
|
|
67
67
|
def extract_mac(raw_data, parsed_interface_data)
|
68
68
|
mac = raw_data.match(/(?:ether|lladdr)\s+((?:\w?\w:){5}\w?\w)|(?:infiniband)\s+((?:\w?\w:){19}\w?\w)/)
|
69
|
-
|
69
|
+
&.captures&.compact&.first
|
70
70
|
parsed_interface_data[:mac] = mac unless mac.nil?
|
71
71
|
end
|
72
72
|
|
@@ -110,7 +110,7 @@ module Facter
|
|
110
110
|
|
111
111
|
def append_linux_to_os_name
|
112
112
|
os_name = @fact_list[:name]
|
113
|
-
@fact_list[:name] = os_name
|
113
|
+
@fact_list[:name] = "#{os_name}Linux" if os_name.downcase.start_with?('virtuozzo')
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -112,9 +112,9 @@ module Facter
|
|
112
112
|
|
113
113
|
def execute_and_extract_blkid_info
|
114
114
|
stdout = Facter::Core::Execution.execute('blkid', logger: log)
|
115
|
-
output_hash = Hash[*stdout.split(/^([^:]+):/)[1
|
115
|
+
output_hash = Hash[*stdout.split(/^([^:]+):/)[1..]]
|
116
116
|
output_hash.each do |key, value|
|
117
|
-
output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1
|
117
|
+
output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..]]
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -26,7 +26,7 @@ module Facter
|
|
26
26
|
|
27
27
|
@fact_list[:major] = major
|
28
28
|
@fact_list[:minor] = minor
|
29
|
-
@fact_list[:full] = major == '10' ? major
|
29
|
+
@fact_list[:full] = major == '10' ? "#{major}_u#{minor}" : "#{major}.#{minor}"
|
30
30
|
break
|
31
31
|
end
|
32
32
|
@fact_list[fact_name]
|
@@ -36,7 +36,7 @@ module Facter
|
|
36
36
|
result = text.match(regex_pattern)
|
37
37
|
major, minor = result.captures if result
|
38
38
|
minor = regex_pattern == /Solaris (\d+)/ ? '0' : minor
|
39
|
-
|
39
|
+
[major, minor] if major && minor
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -30,7 +30,8 @@ module Facter
|
|
30
30
|
xen_info = xen_info.to_s
|
31
31
|
return 'xenu' if /xen-domu/.match?(xen_info)
|
32
32
|
return 'xenhvm' if /xen-hvm/.match?(xen_info)
|
33
|
-
|
33
|
+
|
34
|
+
'xen0' if /xen-dom0/.match?(xen_info)
|
34
35
|
end
|
35
36
|
|
36
37
|
def determine_other(output)
|
@@ -58,8 +58,9 @@ module Facter
|
|
58
58
|
@fact_list[:total_bytes] = result[:total_bytes]
|
59
59
|
@fact_list[:available_bytes] = result[:available_bytes]
|
60
60
|
@fact_list[:used_bytes] = result[:used_bytes]
|
61
|
-
@fact_list[:capacity] = format(
|
62
|
-
|
61
|
+
@fact_list[:capacity] = format(
|
62
|
+
'%<capacity>.2f%%', capacity: (result[:used_bytes] / result[:total_bytes].to_f * 100)
|
63
|
+
)
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -23,19 +23,19 @@ module Facter
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def build_fact_list(reg)
|
26
|
-
reg.each do |name,
|
26
|
+
reg.each do |name, _type, value|
|
27
27
|
case name
|
28
28
|
when 'EditionID'
|
29
|
-
@fact_list[:edition_id] =
|
29
|
+
@fact_list[:edition_id] = value
|
30
30
|
when 'InstallationType'
|
31
|
-
@fact_list[:installation_type] =
|
31
|
+
@fact_list[:installation_type] = value
|
32
32
|
when 'ProductName'
|
33
|
-
@fact_list[:product_name] =
|
33
|
+
@fact_list[:product_name] = value
|
34
34
|
when 'DisplayVersion'
|
35
|
-
@fact_list[:release_id] =
|
36
|
-
@fact_list[:display_version] =
|
35
|
+
@fact_list[:release_id] = value
|
36
|
+
@fact_list[:display_version] = value
|
37
37
|
when 'ReleaseId'
|
38
|
-
@fact_list[:release_id] =
|
38
|
+
@fact_list[:release_id] = value unless @fact_list[:release_id]
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -34,9 +34,9 @@ module Facter
|
|
34
34
|
|
35
35
|
options.split(',').each do |option|
|
36
36
|
if option.start_with?('-')
|
37
|
-
exclude << option[1
|
37
|
+
exclude << option[1..].to_sym
|
38
38
|
elsif option.start_with?('+')
|
39
|
-
print_caller << option[1
|
39
|
+
print_caller << option[1..].to_sym
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -7,11 +7,10 @@ module Facter
|
|
7
7
|
module VirtualDetector
|
8
8
|
class << self
|
9
9
|
def platform
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@@fact_value
|
10
|
+
@fact_value ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
11
|
+
check_docker_lxc || check_freebsd || check_gce || check_illumos_lx || \
|
12
|
+
retrieve_from_virt_what || check_vmware || check_open_vz || check_vserver || \
|
13
|
+
check_xen || check_other_facts || check_lspci || 'physical'
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
@@ -25,6 +24,10 @@ module Facter
|
|
25
24
|
'gce' if bios_vendor&.include?('Google')
|
26
25
|
end
|
27
26
|
|
27
|
+
def check_illumos_lx
|
28
|
+
'illumos-lx' if Facter::Resolvers::Uname.resolve(:kernelversion) == 'BrandZ virtual linux'
|
29
|
+
end
|
30
|
+
|
28
31
|
def check_vmware
|
29
32
|
Facter::Resolvers::Vmware.resolve(:vm)
|
30
33
|
end
|
@@ -19,12 +19,12 @@ module Facter
|
|
19
19
|
|
20
20
|
validated_speed, metric_prefix = determine_metric_prefix(speed)
|
21
21
|
|
22
|
-
format('%<displayed_speed>.2f', displayed_speed: validated_speed.round(2))
|
22
|
+
"#{format('%<displayed_speed>.2f', displayed_speed: validated_speed.round(2))} #{metric_prefix}Hz"
|
23
23
|
end
|
24
24
|
|
25
25
|
def bytes_to_human_readable(bytes)
|
26
26
|
return unless bytes
|
27
|
-
return bytes
|
27
|
+
return "#{bytes} bytes" if bytes < 1024
|
28
28
|
|
29
29
|
number, multiple = determine_exponent(bytes)
|
30
30
|
|
@@ -23,12 +23,12 @@ module Facter
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def output_to_hash(output)
|
26
|
-
output.scan(/.*:
|
26
|
+
output.scan(/.*: .*$/).map { |e| e.strip.match(/(.*?): (.*)/).captures }.to_h
|
27
27
|
end
|
28
28
|
|
29
29
|
def normalize_keys(system_profiler_hash)
|
30
|
-
system_profiler_hash.
|
31
|
-
|
30
|
+
system_profiler_hash.transform_keys do |k|
|
31
|
+
k.downcase.tr(' ', '_').delete("\(\)").to_sym
|
32
32
|
end.to_h
|
33
33
|
end
|
34
34
|
end
|
@@ -54,7 +54,8 @@ module Facter
|
|
54
54
|
'site'
|
55
55
|
elsif addrinfo.ipv6_loopback?
|
56
56
|
'host'
|
57
|
-
else
|
57
|
+
else
|
58
|
+
'global'
|
58
59
|
end
|
59
60
|
scope6.join
|
60
61
|
end
|
@@ -102,7 +103,7 @@ module Facter
|
|
102
103
|
def expand_interfaces(interfaces)
|
103
104
|
interfaces.each_value do |values|
|
104
105
|
expand_binding(values, values[:bindings]) if values[:bindings]
|
105
|
-
expand_binding(values, values[:bindings6], false) if values[:bindings6]
|
106
|
+
expand_binding(values, values[:bindings6], ipv4_type: false) if values[:bindings6]
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
@@ -112,7 +113,7 @@ module Facter
|
|
112
113
|
end
|
113
114
|
end
|
114
115
|
|
115
|
-
def expand_binding(values, bindings, ipv4_type
|
116
|
+
def expand_binding(values, bindings, ipv4_type: true)
|
116
117
|
binding = find_valid_binding(bindings)
|
117
118
|
ip_protocol_type = ipv4_type ? '' : '6'
|
118
119
|
|
data/lib/facter/util/utils.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
module Facter
|
4
4
|
module Utils
|
5
5
|
# Sort nested hash.
|
6
|
-
def self.sort_hash_by_key(hash, recursive
|
6
|
+
def self.sort_hash_by_key(hash, recursive: true, &block)
|
7
7
|
hash.keys.sort(&block).each_with_object(hash.class.new) do |key, seed|
|
8
8
|
seed[key] = hash[key]
|
9
|
-
seed[key] = sort_hash_by_key(seed[key], true, &block) if recursive && seed[key].is_a?(Hash)
|
9
|
+
seed[key] = sort_hash_by_key(seed[key], recursive: true, &block) if recursive && seed[key].is_a?(Hash)
|
10
10
|
|
11
11
|
seed
|
12
12
|
end
|
data/lib/facter/version.rb
CHANGED
data/lib/facter.rb
CHANGED