facter 4.0.52 → 4.2.2
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/LICENSE +202 -0
- data/lib/facter.rb +21 -21
- data/lib/facter/config.rb +2 -0
- data/lib/facter/custom_facts/core/execution/base.rb +7 -3
- data/lib/facter/custom_facts/core/execution/popen3.rb +13 -1
- data/lib/facter/custom_facts/core/execution/posix.rb +2 -2
- data/lib/facter/custom_facts/core/execution/windows.rb +1 -1
- data/lib/facter/custom_facts/util/collection.rb +5 -0
- data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
- data/lib/facter/custom_facts/util/normalization.rb +7 -2
- data/lib/facter/custom_facts/util/windows_root.rb +2 -1
- data/lib/facter/facts/aix/processors/cores.rb +16 -0
- data/lib/facter/facts/aix/processors/threads.rb +16 -0
- data/lib/facter/facts/freebsd/is_virtual.rb +1 -5
- data/lib/facter/facts/freebsd/virtual.rb +1 -2
- data/lib/facter/facts/linux/az_metadata.rb +1 -5
- data/lib/facter/facts/linux/cloud/provider.rb +5 -2
- data/lib/facter/facts/linux/ec2_metadata.rb +1 -5
- data/lib/facter/facts/linux/ec2_userdata.rb +1 -5
- data/lib/facter/facts/linux/hypervisors/xen.rb +1 -4
- data/lib/facter/facts/linux/is_virtual.rb +1 -5
- data/lib/facter/facts/linux/processors/cores.rb +16 -0
- data/lib/facter/facts/linux/processors/threads.rb +16 -0
- data/lib/facter/facts/linux/virtual.rb +1 -2
- data/lib/facter/facts/macosx/os/macosx/version.rb +15 -4
- data/lib/facter/facts/macosx/processors/cores.rb +16 -0
- data/lib/facter/facts/macosx/processors/threads.rb +16 -0
- data/lib/facter/facts/solaris/hypervisors/ldom.rb +1 -1
- data/lib/facter/facts/solaris/hypervisors/zone.rb +1 -1
- data/lib/facter/facts/solaris/mountpoints.rb +1 -1
- data/lib/facter/facts/solaris/processors/cores.rb +16 -0
- data/lib/facter/facts/solaris/processors/threads.rb +16 -0
- data/lib/facter/facts/windows/az_metadata.rb +1 -5
- data/lib/facter/facts/windows/cloud/provider.rb +6 -2
- data/lib/facter/facts/windows/ec2_metadata.rb +1 -1
- data/lib/facter/facts/windows/ec2_userdata.rb +1 -1
- data/lib/facter/facts/windows/gce.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/hyperv.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/kvm.rb +2 -1
- data/lib/facter/facts/windows/hypervisors/virtualbox.rb +2 -2
- data/lib/facter/facts/windows/hypervisors/vmware.rb +1 -1
- data/lib/facter/facts/windows/hypervisors/xen.rb +3 -1
- data/lib/facter/facts/windows/is_virtual.rb +15 -0
- data/lib/facter/facts/windows/{virtualization/is_virtual.rb → processors/cores.rb} +4 -4
- data/lib/facter/facts/windows/{virtualization/virtual.rb → processors/threads.rb} +4 -4
- data/lib/facter/facts/windows/virtual.rb +15 -0
- data/lib/facter/framework/cli/cli.rb +13 -15
- data/lib/facter/framework/core/cache_manager.rb +2 -2
- data/lib/facter/framework/core/fact/external/external_fact_manager.rb +0 -1
- data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +41 -39
- data/lib/facter/framework/core/fact_filter.rb +4 -14
- data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +9 -6
- data/lib/facter/framework/core/fact_loaders/fact_loader.rb +39 -36
- data/lib/facter/framework/core/fact_manager.rb +82 -14
- data/lib/facter/framework/core/file_loader.rb +1 -1
- data/lib/facter/framework/core/options/config_file_options.rb +7 -0
- data/lib/facter/framework/core/options/option_store.rb +3 -1
- data/lib/facter/framework/formatters/formatter_helper.rb +3 -5
- data/lib/facter/framework/parsers/query_parser.rb +10 -24
- data/lib/facter/models/fact_collection.rb +48 -5
- data/lib/facter/models/resolved_fact.rb +2 -3
- data/lib/facter/models/searched_fact.rb +2 -3
- data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
- data/lib/facter/resolvers/aix/processors.rb +4 -0
- data/lib/facter/resolvers/base_resolver.rb +2 -2
- data/lib/facter/resolvers/dmi_decode.rb +0 -1
- data/lib/facter/resolvers/ec2.rb +8 -1
- data/lib/facter/resolvers/linux/hostname.rb +16 -5
- data/lib/facter/resolvers/linux/networking.rb +18 -1
- data/lib/facter/resolvers/lsb_release.rb +1 -2
- data/lib/facter/resolvers/macosx/mountpoints.rb +14 -1
- data/lib/facter/resolvers/macosx/processor.rb +16 -1
- data/lib/facter/resolvers/mountpoints.rb +16 -8
- data/lib/facter/resolvers/networking.rb +6 -3
- data/lib/facter/resolvers/partitions.rb +1 -3
- data/lib/facter/resolvers/processors_lscpu.rb +44 -0
- data/lib/facter/resolvers/ruby.rb +1 -1
- data/lib/facter/resolvers/selinux.rb +5 -7
- data/lib/facter/resolvers/solaris/ffi/structs.rb +12 -0
- data/lib/facter/resolvers/solaris/mountpoints.rb +22 -16
- data/lib/facter/resolvers/solaris/networking.rb +20 -5
- data/lib/facter/resolvers/solaris/processors.rb +7 -0
- data/lib/facter/resolvers/solaris/zone.rb +0 -1
- data/lib/facter/resolvers/windows/ffi/identity_ffi.rb +5 -0
- data/lib/facter/resolvers/windows/ffi/kernel_ffi.rb +1 -1
- data/lib/facter/resolvers/windows/identity.rb +1 -6
- data/lib/facter/resolvers/windows/processors.rb +41 -4
- data/lib/facter/resolvers/windows/uptime.rb +3 -22
- data/lib/facter/resolvers/windows/virtualization.rb +46 -44
- data/lib/facter/resolvers/xen.rb +6 -1
- data/lib/facter/templates/man.erb +6 -6
- data/lib/facter/util/facts/posix/virtual_detector.rb +74 -0
- data/lib/facter/util/facts/unit_converter.rb +2 -2
- data/lib/facter/util/linux/dhcp.rb +4 -1
- data/lib/facter/util/linux/if_inet6.rb +73 -0
- data/lib/facter/util/linux/socket_parser.rb +18 -3
- data/lib/facter/util/resolvers/http.rb +7 -1
- data/lib/facter/util/resolvers/networking/primary_interface.rb +11 -5
- data/lib/facter/util/utils.rb +18 -1
- data/lib/facter/version.rb +1 -1
- metadata +60 -11
- data/lib/facter/framework/core/fact_augmenter.rb +0 -37
- data/lib/facter/util/facts/virtual_detector.rb +0 -90
data/lib/facter/resolvers/ec2.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Facter
|
|
|
51
51
|
|
|
52
52
|
def get_data_from(url)
|
|
53
53
|
headers = {}
|
|
54
|
-
headers['X-aws-ec2-metadata-token'] =
|
|
54
|
+
headers['X-aws-ec2-metadata-token'] = v2_token if v2_token
|
|
55
55
|
Facter::Util::Resolvers::Http.get_request(url, headers, { session: determine_session_timeout })
|
|
56
56
|
end
|
|
57
57
|
|
|
@@ -59,6 +59,13 @@ module Facter
|
|
|
59
59
|
session_env = ENV['EC2_SESSION_TIMEOUT']
|
|
60
60
|
session_env ? session_env.to_i : EC2_SESSION_TIMEOUT
|
|
61
61
|
end
|
|
62
|
+
|
|
63
|
+
def v2_token
|
|
64
|
+
@v2_token ||= begin
|
|
65
|
+
token = Facter::Util::Resolvers::AwsToken.get
|
|
66
|
+
token == '' ? nil : token
|
|
67
|
+
end
|
|
68
|
+
end
|
|
62
69
|
end
|
|
63
70
|
end
|
|
64
71
|
end
|
|
@@ -19,7 +19,6 @@ module Facter
|
|
|
19
19
|
|
|
20
20
|
def retrieve_info(fact_name)
|
|
21
21
|
require 'socket'
|
|
22
|
-
require 'facter/util/resolvers/ffi/hostname'
|
|
23
22
|
|
|
24
23
|
output = retrieving_hostname
|
|
25
24
|
return nil unless output
|
|
@@ -38,13 +37,20 @@ module Facter
|
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
def retrieving_hostname
|
|
41
|
-
output = Socket.gethostname
|
|
42
|
-
if
|
|
43
|
-
|
|
40
|
+
output = Socket.gethostname || ''
|
|
41
|
+
if output.empty? || output['0.0.0.0']
|
|
42
|
+
begin
|
|
43
|
+
require 'facter/util/resolvers/ffi/hostname'
|
|
44
|
+
|
|
45
|
+
output = Facter::Util::Resolvers::Ffi::Hostname.getffihostname
|
|
46
|
+
rescue LoadError => e
|
|
47
|
+
log.debug(e.message)
|
|
48
|
+
output = nil
|
|
49
|
+
end
|
|
44
50
|
end
|
|
45
51
|
|
|
46
52
|
log.debug("Tried to retrieve hostname and got: #{output}")
|
|
47
|
-
output
|
|
53
|
+
return output unless output&.empty?
|
|
48
54
|
end
|
|
49
55
|
|
|
50
56
|
def parse_fqdn(output)
|
|
@@ -70,9 +76,14 @@ module Facter
|
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
def retrieve_fqdn_for_host_with_ffi(host)
|
|
79
|
+
require 'facter/util/resolvers/ffi/hostname'
|
|
80
|
+
|
|
73
81
|
fqdn = Facter::Util::Resolvers::Ffi::Hostname.getffiaddrinfo(host)
|
|
74
82
|
log.debug("FFI getaddrinfo was called and it retrieved: #{fqdn}")
|
|
75
83
|
fqdn
|
|
84
|
+
rescue LoadError => e
|
|
85
|
+
log.debug(e.message)
|
|
86
|
+
nil
|
|
76
87
|
end
|
|
77
88
|
|
|
78
89
|
def exists_and_valid_fqdn?(fqdn, hostname)
|
|
@@ -20,6 +20,7 @@ module Facter
|
|
|
20
20
|
add_info_from_routing_table
|
|
21
21
|
retrieve_primary_interface
|
|
22
22
|
Facter::Util::Resolvers::Networking.expand_main_bindings(@fact_list)
|
|
23
|
+
add_flags
|
|
23
24
|
@fact_list[fact_name]
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -43,7 +44,6 @@ module Facter
|
|
|
43
44
|
|
|
44
45
|
parse_ip_command_line(line, mtu_and_indexes)
|
|
45
46
|
end
|
|
46
|
-
log.debug("Associated MTU and index in ip command: #{mtu_and_indexes}")
|
|
47
47
|
mtu_and_indexes
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -72,6 +72,23 @@ module Facter
|
|
|
72
72
|
compare_ips(routes6, :bindings6)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
def add_flags
|
|
76
|
+
flags = Facter::Util::Linux::IfInet6.read_flags
|
|
77
|
+
flags.each_pair do |iface, ips|
|
|
78
|
+
next unless @fact_list[:interfaces].key?(iface)
|
|
79
|
+
|
|
80
|
+
ips.each_pair do |ip, ip_flags|
|
|
81
|
+
next unless @fact_list[:interfaces][iface].key?(:bindings6)
|
|
82
|
+
|
|
83
|
+
@fact_list[:interfaces][iface][:bindings6].each do |binding|
|
|
84
|
+
next unless binding[:address] == ip
|
|
85
|
+
|
|
86
|
+
binding[:flags] = ip_flags
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
75
92
|
def compare_ips(routes, binding_key)
|
|
76
93
|
routes.each do |route|
|
|
77
94
|
next unless @fact_list[:interfaces].key?(route[:interface])
|
|
@@ -25,8 +25,7 @@ module Facter
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def lsb_release_installed?
|
|
28
|
-
|
|
29
|
-
@fact_list[:lsb_release_installed] = !output.empty?
|
|
28
|
+
@fact_list[:lsb_release_installed] = !Facter::Core::Execution.which('lsb_release').nil?
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
def read_lsb_release_file
|
|
@@ -21,7 +21,7 @@ module Facter
|
|
|
21
21
|
device = fs.name
|
|
22
22
|
filesystem = fs.mount_type
|
|
23
23
|
path = fs.mount_point
|
|
24
|
-
options = fs.options
|
|
24
|
+
options = read_options(fs.options)
|
|
25
25
|
|
|
26
26
|
mounts[path] = read_stats(path).tap do |hash|
|
|
27
27
|
hash[:device] = device
|
|
@@ -53,6 +53,19 @@ module Facter
|
|
|
53
53
|
used: Facter::Util::Facts::UnitConverter.bytes_to_human_readable(used_bytes)
|
|
54
54
|
}
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
def read_options(options)
|
|
58
|
+
options_map = {
|
|
59
|
+
'read-only' => 'readonly',
|
|
60
|
+
'asynchronous' => 'async',
|
|
61
|
+
'synchronous' => 'noasync',
|
|
62
|
+
'quotas' => 'quota',
|
|
63
|
+
'rootfs' => 'root',
|
|
64
|
+
'defwrite' => 'deferwrites'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
options.split(',').map(&:strip).map { |o| options_map.key?(o) ? options_map[o] : o }
|
|
68
|
+
end
|
|
56
69
|
end
|
|
57
70
|
end
|
|
58
71
|
end
|
|
@@ -9,12 +9,17 @@ module Facter
|
|
|
9
9
|
ITEMS = { logical_count: 'hw.logicalcpu_max',
|
|
10
10
|
physical_count: 'hw.physicalcpu_max',
|
|
11
11
|
brand: 'machdep.cpu.brand_string',
|
|
12
|
-
speed: 'hw.cpufrequency_max'
|
|
12
|
+
speed: 'hw.cpufrequency_max',
|
|
13
|
+
cores_per_socket: 'machdep.cpu.core_count',
|
|
14
|
+
threads_per_core: 'machdep.cpu.thread_count' }.freeze
|
|
15
|
+
|
|
13
16
|
class << self
|
|
14
17
|
# :logicalcount
|
|
15
18
|
# :models
|
|
16
19
|
# :physicalcount
|
|
17
20
|
# :speed
|
|
21
|
+
# :cores_per_socket
|
|
22
|
+
# :threads_per_core
|
|
18
23
|
|
|
19
24
|
private
|
|
20
25
|
|
|
@@ -33,6 +38,8 @@ module Facter
|
|
|
33
38
|
build_physical_count(processors_data[1])
|
|
34
39
|
build_models(processors_data[2])
|
|
35
40
|
build_speed(processors_data[3])
|
|
41
|
+
build_cores_per_socket(processors_data[4])
|
|
42
|
+
build_threads_per_core(processors_data[5], processors_data[4])
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
def build_logical_count(count)
|
|
@@ -51,6 +58,14 @@ module Facter
|
|
|
51
58
|
def build_speed(value)
|
|
52
59
|
@fact_list[:speed] = value.split(': ')[1].to_i
|
|
53
60
|
end
|
|
61
|
+
|
|
62
|
+
def build_cores_per_socket(count)
|
|
63
|
+
@fact_list[:cores_per_socket] = count.split(': ')[1].to_i
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def build_threads_per_core(number_of_threads, number_of_cores)
|
|
67
|
+
@fact_list[:threads_per_core] = number_of_threads.split(': ')[1].to_i / number_of_cores.split(': ')[1].to_i
|
|
68
|
+
end
|
|
54
69
|
end
|
|
55
70
|
end
|
|
56
71
|
end
|
|
@@ -67,10 +67,24 @@ module Facter
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def get_mount_sizes(mount)
|
|
70
|
-
|
|
70
|
+
begin
|
|
71
|
+
stats = Facter::Util::Resolvers::FilesystemHelper.read_mountpoint_stats(mount[:path])
|
|
72
|
+
get_bytes_data(mount, stats)
|
|
73
|
+
rescue Sys::Filesystem::Error => e
|
|
74
|
+
@log.debug("Could not get stats for mountpoint #{mount[:path]}, got #{e}")
|
|
75
|
+
mount[:size_bytes] = mount[:available_bytes] = mount[:used_bytes] = 0
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
populate_mount(mount)
|
|
79
|
+
end
|
|
71
80
|
|
|
72
|
-
|
|
81
|
+
def get_bytes_data(mount, stats)
|
|
82
|
+
mount[:size_bytes] = stats.bytes_total.abs
|
|
83
|
+
mount[:available_bytes] = stats.bytes_available.abs
|
|
84
|
+
mount[:used_bytes] = stats.bytes_used.abs
|
|
85
|
+
end
|
|
73
86
|
|
|
87
|
+
def populate_mount(mount)
|
|
74
88
|
total_bytes = mount[:used_bytes] + mount[:available_bytes]
|
|
75
89
|
mount[:capacity] = Facter::Util::Resolvers::FilesystemHelper.compute_capacity(mount[:used_bytes], total_bytes)
|
|
76
90
|
|
|
@@ -78,12 +92,6 @@ module Facter
|
|
|
78
92
|
mount[:available] = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(mount[:available_bytes])
|
|
79
93
|
mount[:used] = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(mount[:used_bytes])
|
|
80
94
|
end
|
|
81
|
-
|
|
82
|
-
def get_bytes_data(mount, stats)
|
|
83
|
-
mount[:size_bytes] = stats.bytes_total.abs
|
|
84
|
-
mount[:available_bytes] = stats.bytes_available.abs
|
|
85
|
-
mount[:used_bytes] = stats.bytes_used.abs
|
|
86
|
-
end
|
|
87
95
|
end
|
|
88
96
|
end
|
|
89
97
|
end
|
|
@@ -37,12 +37,14 @@ module Facter
|
|
|
37
37
|
|
|
38
38
|
def clean_up_interfaces_response(response)
|
|
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
|
+
# 2001:db8:cafe::132:213 is converted to 2001:db8:cafe::132:213
|
|
42
|
+
response.gsub!(/([\da-fA-F]+([\.:]+[\da-fA-F]+)*)\s+-->\s+[\da-fA-F]+([\.:]+[\da-fA-F]+)*/, '\\1')
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def parse_interfaces_response(response)
|
|
44
46
|
parsed_interfaces_data = {}
|
|
45
|
-
interfaces_data = Hash[*response.split(/^([A-Za-z0-9_]+): /)[1..-1]]
|
|
47
|
+
interfaces_data = Hash[*response.split(/^([A-Za-z0-9_\.]+): /)[1..-1]]
|
|
46
48
|
|
|
47
49
|
interfaces_data.each do |interface_name, raw_data|
|
|
48
50
|
parsed_interface_data = {}
|
|
@@ -63,7 +65,8 @@ module Facter
|
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
def extract_mac(raw_data, parsed_interface_data)
|
|
66
|
-
mac = raw_data.match(/(?:ether|lladdr)\s+(
|
|
68
|
+
mac = raw_data.match(/(?:ether|lladdr)\s+((?:\w?\w:){5}\w?\w)|(?:infiniband)\s+((?:\w?\w:){19}\w?\w)/)
|
|
69
|
+
&.captures&.compact&.first
|
|
67
70
|
parsed_interface_data[:mac] = mac unless mac.nil?
|
|
68
71
|
end
|
|
69
72
|
|
|
@@ -107,9 +107,7 @@ module Facter
|
|
|
107
107
|
|
|
108
108
|
return blkid_and_lsblk[command_exists_key] unless blkid_and_lsblk[command_exists_key].nil?
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
blkid_and_lsblk[:command_exists_key] = !output.empty?
|
|
110
|
+
blkid_and_lsblk[command_exists_key] = !Facter::Core::Execution.which(command).nil?
|
|
113
111
|
end
|
|
114
112
|
|
|
115
113
|
def execute_and_extract_blkid_info
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Facter
|
|
4
|
+
module Resolvers
|
|
5
|
+
module Linux
|
|
6
|
+
class Lscpu < BaseResolver
|
|
7
|
+
init_resolver
|
|
8
|
+
|
|
9
|
+
ITEMS = { threads_per_core: "-e 'Thread(s)'",
|
|
10
|
+
cores_per_socket: "-e 'Core(s)'" }.freeze
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
#:cores_per_socket
|
|
14
|
+
#:threads_per_core
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def post_resolve(fact_name, _options)
|
|
19
|
+
@fact_list.fetch(fact_name) { read_cpuinfo(fact_name) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def read_cpuinfo(fact_name)
|
|
23
|
+
lscpu_output = Facter::Core::Execution.execute("lscpu | grep #{ITEMS.values.join(' ')}", logger: log)
|
|
24
|
+
build_fact_list(lscpu_output.split("\n"))
|
|
25
|
+
@fact_list[fact_name]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def build_fact_list(processors_data)
|
|
29
|
+
build_threads_per_core(processors_data[0])
|
|
30
|
+
build_cores_per_socket(processors_data[1])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def build_threads_per_core(index)
|
|
34
|
+
@fact_list[:threads_per_core] = index.split(': ')[1].to_i
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def build_cores_per_socket(index)
|
|
38
|
+
@fact_list[:cores_per_socket] = index.split(': ')[1].to_i
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -13,7 +13,7 @@ module Facter
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def retrieve_ruby_information(fact_name)
|
|
16
|
-
@fact_list[:sitedir] = RbConfig::CONFIG['sitelibdir']
|
|
16
|
+
@fact_list[:sitedir] = RbConfig::CONFIG['sitelibdir'] if RbConfig::CONFIG['sitedir']
|
|
17
17
|
@fact_list[:platform] = RUBY_PLATFORM
|
|
18
18
|
@fact_list[:version] = RUBY_VERSION
|
|
19
19
|
@fact_list[fact_name]
|
|
@@ -13,21 +13,21 @@ module Facter
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def retrieve_facts(fact_name)
|
|
16
|
-
mountpoint =
|
|
16
|
+
mountpoint = selinux_mountpoint
|
|
17
|
+
|
|
18
|
+
@fact_list[:enabled] = !mountpoint.empty? && read_selinux_config
|
|
17
19
|
read_other_selinux_facts(mountpoint) if @fact_list[:enabled]
|
|
18
20
|
|
|
19
21
|
@fact_list[fact_name]
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
def
|
|
24
|
+
def selinux_mountpoint
|
|
23
25
|
output = Facter::Core::Execution.execute('cat /proc/self/mounts', logger: log)
|
|
24
|
-
@fact_list[:enabled] = false
|
|
25
26
|
mountpoint = ''
|
|
26
27
|
|
|
27
28
|
output.each_line do |line|
|
|
28
29
|
next unless line =~ /selinuxfs/
|
|
29
30
|
|
|
30
|
-
@fact_list[:enabled] = true
|
|
31
31
|
mountpoint = line.split("\s")[1]
|
|
32
32
|
break
|
|
33
33
|
end
|
|
@@ -35,8 +35,6 @@ module Facter
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def read_other_selinux_facts(mountpoint)
|
|
38
|
-
return unless read_selinux_config
|
|
39
|
-
|
|
40
38
|
enforce_file = "#{mountpoint}/enforce"
|
|
41
39
|
policy_file = "#{mountpoint}/policyvers"
|
|
42
40
|
|
|
@@ -60,7 +58,7 @@ module Facter
|
|
|
60
58
|
@fact_list[:config_policy] = line.split('=').last.strip if line =~ /^SELINUXTYPE=/
|
|
61
59
|
end
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
!file_lines.empty? ? true : false
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
end
|
|
@@ -111,6 +111,18 @@ module Facter
|
|
|
111
111
|
self[:sin_addr][:s_addr]
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
|
+
|
|
115
|
+
class In6Addr < ::FFI::Struct
|
|
116
|
+
layout :s_addr, [:uint32_t, 4]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
class SockaddrIn6 < ::FFI::Struct
|
|
120
|
+
layout :sin6_family, :sa_family_t,
|
|
121
|
+
:sin6_port, :in_port_t,
|
|
122
|
+
:sin6_flowinfo, :uint32_t,
|
|
123
|
+
:sin6_addr, In6Addr,
|
|
124
|
+
:sin6_scope_id, :uint32_t
|
|
125
|
+
end
|
|
114
126
|
end
|
|
115
127
|
end
|
|
116
128
|
end
|
|
@@ -14,23 +14,26 @@ module Facter
|
|
|
14
14
|
@fact_list.fetch(fact_name) { read_mounts(fact_name) }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def compute_device(device)
|
|
24
|
-
# If the "root" device, lookup the actual device from the kernel options
|
|
25
|
-
# This is done because not all systems symlink /dev/root
|
|
26
|
-
device = root_device if device == '/dev/root'
|
|
27
|
-
device
|
|
17
|
+
def exclude_auto_home_mounts!
|
|
18
|
+
@mounts.reject! do |mount|
|
|
19
|
+
parent = mount[:path].rpartition('/').first
|
|
20
|
+
@auto_home_paths.include?(parent)
|
|
21
|
+
end
|
|
28
22
|
end
|
|
29
23
|
|
|
30
24
|
def read_mounts(fact_name) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
31
|
-
mounts = []
|
|
25
|
+
@mounts = []
|
|
26
|
+
@auto_home_paths = []
|
|
27
|
+
|
|
32
28
|
Facter::Util::Resolvers::FilesystemHelper.read_mountpoints.each do |fs|
|
|
33
|
-
|
|
29
|
+
if fs.name == 'auto_home'
|
|
30
|
+
@auto_home_paths << fs.mount_point
|
|
31
|
+
next
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
next if fs.mount_type == 'autofs'
|
|
35
|
+
|
|
36
|
+
device = fs.name
|
|
34
37
|
filesystem = fs.mount_type
|
|
35
38
|
path = fs.mount_point
|
|
36
39
|
options = fs.options.split(',').map(&:strip)
|
|
@@ -47,11 +50,14 @@ module Facter
|
|
|
47
50
|
available = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(available_bytes)
|
|
48
51
|
used = Facter::Util::Facts::UnitConverter.bytes_to_human_readable(used_bytes)
|
|
49
52
|
|
|
50
|
-
mounts << Hash[Facter::Util::Resolvers::FilesystemHelper::MOUNT_KEYS
|
|
51
|
-
|
|
53
|
+
@mounts << Hash[Facter::Util::Resolvers::FilesystemHelper::MOUNT_KEYS
|
|
54
|
+
.zip(Facter::Util::Resolvers::FilesystemHelper::MOUNT_KEYS
|
|
52
55
|
.map { |v| binding.local_variable_get(v) })]
|
|
53
56
|
end
|
|
54
|
-
|
|
57
|
+
|
|
58
|
+
exclude_auto_home_mounts!
|
|
59
|
+
|
|
60
|
+
@fact_list[:mountpoints] = @mounts
|
|
55
61
|
@fact_list[fact_name]
|
|
56
62
|
end
|
|
57
63
|
end
|