facter 4.0.9.pre → 4.0.10.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rtc.yml +11 -0
- data/.rubocop_todo.yml +10 -190
- data/VERSION +1 -1
- data/facter.gemspec +1 -0
- data/lib/custom_facts/core/aggregate.rb +4 -6
- data/lib/custom_facts/core/execution.rb +1 -1
- data/lib/custom_facts/core/execution/base.rb +15 -24
- data/lib/custom_facts/core/execution/posix.rb +2 -2
- data/lib/custom_facts/core/resolvable.rb +1 -1
- data/lib/custom_facts/core/suitable.rb +2 -1
- data/lib/custom_facts/util/fact.rb +3 -3
- data/lib/custom_facts/util/loader.rb +2 -2
- data/lib/custom_facts/util/parser.rb +7 -7
- data/lib/custom_facts/util/resolution.rb +1 -3
- data/lib/custom_facts/version.rb +1 -1
- data/lib/facter.rb +217 -41
- data/lib/facts/aix/augeas/version.rb +4 -1
- data/lib/facts/aix/filesystems.rb +14 -0
- data/lib/facts/aix/identity/user.rb +17 -0
- data/lib/facts/aix/puppet_version.rb +15 -0
- data/lib/facts/aix/system_uptime/days.rb +16 -0
- data/lib/facts/aix/system_uptime/hours.rb +16 -0
- data/lib/facts/aix/system_uptime/seconds.rb +16 -0
- data/lib/facts/aix/system_uptime/uptime.rb +16 -0
- data/lib/facts/aix/timezone.rb +14 -0
- data/lib/facts/debian/augeas/version.rb +19 -0
- data/lib/facts/debian/dmi/bios/release_date.rb +2 -1
- data/lib/facts/debian/dmi/bios/vendor.rb +2 -1
- data/lib/facts/debian/dmi/bios/version.rb +2 -1
- data/lib/facts/debian/dmi/board/manufacturer.rb +2 -1
- data/lib/facts/debian/dmi/board/product.rb +2 -1
- data/lib/facts/debian/dmi/board/serial_number.rb +2 -1
- data/lib/facts/debian/dmi/chassis/asset_tag.rb +2 -1
- data/lib/facts/debian/dmi/chassis/type.rb +2 -1
- data/lib/facts/debian/dmi/manufacturer.rb +2 -1
- data/lib/facts/debian/dmi/product/name.rb +2 -1
- data/lib/facts/debian/identity/user.rb +17 -0
- data/lib/facts/debian/interfaces.rb +16 -0
- data/lib/facts/debian/memory/swap/available.rb +2 -1
- data/lib/facts/debian/memory/swap/available_bytes.rb +4 -1
- data/lib/facts/debian/memory/swap/total.rb +2 -1
- data/lib/facts/debian/memory/swap/total_bytes.rb +3 -1
- data/lib/facts/debian/memory/system/available.rb +3 -1
- data/lib/facts/debian/memory/system/available_bytes.rb +4 -1
- data/lib/facts/debian/memory/system/total.rb +2 -1
- data/lib/facts/debian/memory/system/total_bytes.rb +3 -1
- data/lib/facts/debian/networking/mac.rb +18 -0
- data/lib/facts/debian/os/distro/codename.rb +21 -0
- data/lib/facts/debian/os/distro/description.rb +21 -0
- data/lib/facts/debian/os/distro/id.rb +21 -0
- data/lib/facts/debian/os/distro/release.rb +31 -0
- data/lib/facts/debian/os/distro/specification.rb +21 -0
- data/lib/facts/debian/os/hardware.rb +2 -1
- data/lib/facts/debian/os/selinux/config_mode.rb +21 -0
- data/lib/facts/debian/os/selinux/config_policy.rb +21 -0
- data/lib/facts/debian/os/selinux/current_mode.rb +21 -0
- data/lib/facts/debian/os/selinux/enabled.rb +21 -0
- data/lib/facts/debian/os/selinux/enforced.rb +21 -0
- data/lib/facts/debian/os/selinux/policy_version.rb +21 -0
- data/lib/facts/debian/processors/count.rb +2 -1
- data/lib/facts/debian/processors/isa.rb +3 -2
- data/lib/facts/debian/processors/physicalcount.rb +2 -1
- data/lib/facts/debian/puppet_version.rb +15 -0
- data/lib/facts/debian/ruby/platform.rb +2 -1
- data/lib/facts/debian/ruby/sitedir.rb +2 -1
- data/lib/facts/debian/system_uptime/days.rb +2 -1
- data/lib/facts/debian/system_uptime/hours.rb +2 -1
- data/lib/facts/debian/system_uptime/seconds.rb +18 -0
- data/lib/facts/debian/system_uptime/uptime.rb +2 -1
- data/lib/facts/el/augeas/version.rb +19 -0
- data/lib/facts/el/dmi/bios/release_date.rb +2 -1
- data/lib/facts/el/dmi/bios/vendor.rb +2 -1
- data/lib/facts/el/dmi/bios/version.rb +2 -1
- data/lib/facts/el/dmi/board/manufacturer.rb +2 -1
- data/lib/facts/el/dmi/board/product.rb +2 -1
- data/lib/facts/el/dmi/board/serial_number.rb +2 -1
- data/lib/facts/el/dmi/chassis/asset_tag.rb +2 -1
- data/lib/facts/el/dmi/chassis/type.rb +2 -1
- data/lib/facts/el/dmi/manufacturer.rb +2 -1
- data/lib/facts/el/dmi/product/name.rb +2 -1
- data/lib/facts/el/dmi/product/serial_number.rb +2 -1
- data/lib/facts/el/dmi/product/uuid.rb +2 -1
- data/lib/facts/el/identity/user.rb +17 -0
- data/lib/facts/el/interfaces.rb +16 -0
- data/lib/facts/el/memory/swap/available.rb +2 -1
- data/lib/facts/el/memory/swap/available_bytes.rb +3 -1
- data/lib/facts/el/memory/swap/total.rb +2 -1
- data/lib/facts/el/memory/swap/total_bytes.rb +3 -1
- data/lib/facts/el/memory/system/available.rb +2 -1
- data/lib/facts/el/memory/system/available_bytes.rb +3 -1
- data/lib/facts/el/memory/system/total.rb +2 -1
- data/lib/facts/el/memory/system/total_bytes.rb +3 -1
- data/lib/facts/el/networking/mac.rb +18 -0
- data/lib/facts/el/os/distro/codename.rb +21 -0
- data/lib/facts/el/os/distro/description.rb +21 -0
- data/lib/facts/el/os/distro/id.rb +21 -0
- data/lib/facts/el/os/distro/release.rb +31 -0
- data/lib/facts/el/os/distro/specification.rb +21 -0
- data/lib/facts/el/os/hardware.rb +2 -1
- data/lib/facts/el/os/selinux/config_mode.rb +21 -0
- data/lib/facts/el/os/selinux/config_policy.rb +21 -0
- data/lib/facts/el/os/selinux/current_mode.rb +21 -0
- data/lib/facts/el/os/selinux/enabled.rb +21 -0
- data/lib/facts/el/os/selinux/enforced.rb +21 -0
- data/lib/facts/el/os/selinux/policy_version.rb +21 -0
- data/lib/facts/el/processor.rb +19 -0
- data/lib/facts/el/processors/count.rb +2 -1
- data/lib/facts/el/processors/isa.rb +3 -1
- data/lib/facts/el/processors/physicalcount.rb +3 -1
- data/lib/facts/el/puppet_version.rb +15 -0
- data/lib/facts/el/ruby/platform.rb +3 -1
- data/lib/facts/el/ruby/sitedir.rb +3 -1
- data/lib/facts/el/ruby/version.rb +1 -0
- data/lib/facts/el/sshalgorithmkey.rb +16 -0
- data/lib/facts/el/sshfp_algorithm.rb +19 -0
- data/lib/facts/el/system_uptime/days.rb +3 -1
- data/lib/facts/el/system_uptime/hours.rb +3 -1
- data/lib/facts/el/system_uptime/seconds.rb +3 -1
- data/lib/facts/el/system_uptime/uptime.rb +3 -1
- data/lib/facts/macosx/augeas/version.rb +19 -0
- data/lib/facts/macosx/dmi/product/name.rb +2 -1
- data/lib/facts/macosx/identity/group.rb +2 -0
- data/lib/facts/macosx/identity/user.rb +2 -1
- data/lib/facts/macosx/interfaces.rb +15 -0
- data/lib/facts/macosx/memory/swap/available.rb +2 -1
- data/lib/facts/macosx/memory/swap/available_bytes.rb +3 -1
- data/lib/facts/macosx/memory/swap/encrypted.rb +2 -1
- data/lib/facts/macosx/memory/swap/total.rb +2 -1
- data/lib/facts/macosx/memory/swap/total_bytes.rb +3 -1
- data/lib/facts/macosx/memory/system/available.rb +2 -1
- data/lib/facts/macosx/memory/system/available_bytes.rb +3 -1
- data/lib/facts/macosx/memory/system/total.rb +2 -1
- data/lib/facts/macosx/memory/system/total_bytes.rb +3 -1
- data/lib/facts/macosx/networking/mac.rb +18 -0
- data/lib/facts/macosx/os/hardware.rb +2 -1
- data/lib/facts/macosx/os/macosx/build.rb +2 -2
- data/lib/facts/macosx/os/macosx/product.rb +2 -2
- data/lib/facts/macosx/os/macosx/version.rb +5 -1
- data/lib/facts/macosx/os/release.rb +11 -5
- data/lib/facts/macosx/processors/count.rb +2 -1
- data/lib/facts/macosx/processors/isa.rb +2 -1
- data/lib/facts/macosx/processors/models.rb +6 -1
- data/lib/facts/macosx/processors/physicalcount.rb +2 -1
- data/lib/facts/macosx/{augeas.rb → puppet_version.rb} +4 -3
- data/lib/facts/macosx/ruby/platform.rb +2 -2
- data/lib/facts/macosx/ruby/sitedir.rb +2 -2
- data/lib/facts/macosx/ssh.rb +26 -0
- data/lib/facts/macosx/sshalgorithmkey.rb +16 -0
- data/lib/facts/macosx/sshfp_algorithm.rb +19 -0
- data/lib/facts/macosx/system_profiler/boot_mode.rb +2 -1
- data/lib/facts/macosx/system_profiler/boot_rom_version.rb +2 -1
- data/lib/facts/macosx/system_profiler/boot_volume.rb +2 -1
- data/lib/facts/macosx/system_profiler/computer_name.rb +2 -1
- data/lib/facts/macosx/system_profiler/cores.rb +2 -1
- data/lib/facts/macosx/system_profiler/hardware_uuid.rb +2 -1
- data/lib/facts/macosx/system_profiler/kernel_version.rb +2 -1
- data/lib/facts/macosx/system_profiler/l2_cache_per_core.rb +2 -1
- data/lib/facts/macosx/system_profiler/l3_cache.rb +2 -1
- data/lib/facts/macosx/system_profiler/memory.rb +2 -1
- data/lib/facts/macosx/system_profiler/model_identifier.rb +2 -1
- data/lib/facts/macosx/system_profiler/model_name.rb +2 -1
- data/lib/facts/macosx/system_profiler/processor_name.rb +2 -1
- data/lib/facts/macosx/system_profiler/processor_speed.rb +2 -1
- data/lib/facts/macosx/system_profiler/processors.rb +2 -1
- data/lib/facts/macosx/system_profiler/secure_virtual_memory.rb +2 -1
- data/lib/facts/macosx/system_profiler/serial_number.rb +2 -1
- data/lib/facts/macosx/system_profiler/smc_version.rb +2 -1
- data/lib/facts/macosx/system_profiler/system_version.rb +2 -1
- data/lib/facts/macosx/system_profiler/uptime.rb +2 -1
- data/lib/facts/macosx/system_profiler/username.rb +2 -1
- data/lib/facts/macosx/system_uptime/days.rb +2 -1
- data/lib/facts/macosx/system_uptime/hours.rb +2 -1
- data/lib/facts/macosx/system_uptime/seconds.rb +2 -1
- data/lib/facts/macosx/system_uptime/uptime.rb +2 -1
- data/lib/facts/sles/augeas/version.rb +19 -0
- data/lib/facts/sles/disks.rb +15 -0
- data/lib/facts/sles/dmi/bios/release_date.rb +19 -0
- data/lib/facts/sles/dmi/bios/vendor.rb +19 -0
- data/lib/facts/sles/dmi/bios/version.rb +19 -0
- data/lib/facts/sles/dmi/board/manufacturer.rb +19 -0
- data/lib/facts/sles/dmi/board/product.rb +19 -0
- data/lib/facts/sles/dmi/board/serial_number.rb +19 -0
- data/lib/facts/sles/dmi/chassis/asset_tag.rb +19 -0
- data/lib/facts/sles/dmi/chassis/type.rb +19 -0
- data/lib/facts/sles/dmi/manufacturer.rb +17 -0
- data/lib/facts/sles/dmi/product/name.rb +19 -0
- data/lib/facts/sles/dmi/product/serial_number.rb +19 -0
- data/lib/facts/sles/dmi/product/uuid.rb +19 -0
- data/lib/facts/sles/filesystems.rb +14 -0
- data/lib/facts/sles/fips_enabled.rb +14 -0
- data/lib/facts/sles/identity/user.rb +17 -0
- data/lib/facts/sles/interfaces.rb +16 -0
- data/lib/facts/sles/load_averages.rb +14 -0
- data/lib/facts/sles/memory/swap/available.rb +2 -1
- data/lib/facts/sles/memory/swap/available_bytes.rb +3 -1
- data/lib/facts/sles/memory/swap/total.rb +2 -1
- data/lib/facts/sles/memory/swap/total_bytes.rb +3 -1
- data/lib/facts/sles/memory/swap/used.rb +1 -1
- data/lib/facts/sles/memory/swap/used_bytes.rb +1 -1
- data/lib/facts/sles/memory/system/available.rb +2 -1
- data/lib/facts/sles/memory/system/available_bytes.rb +3 -1
- data/lib/facts/sles/memory/system/total.rb +2 -1
- data/lib/facts/sles/memory/system/total_bytes.rb +3 -1
- data/lib/facts/sles/mountpoints.rb +21 -0
- data/lib/facts/sles/networking/mac.rb +18 -0
- data/lib/facts/sles/os/distro/codename.rb +21 -0
- data/lib/facts/sles/os/distro/description.rb +21 -0
- data/lib/facts/sles/os/distro/id.rb +21 -0
- data/lib/facts/sles/os/distro/release.rb +31 -0
- data/lib/facts/sles/os/distro/specification.rb +21 -0
- data/lib/facts/sles/os/family.rb +1 -1
- data/lib/facts/sles/os/hardware.rb +2 -1
- data/lib/facts/sles/os/release.rb +3 -3
- data/lib/facts/sles/os/selinux/config_mode.rb +21 -0
- data/lib/facts/sles/os/selinux/config_policy.rb +21 -0
- data/lib/facts/sles/os/selinux/current_mode.rb +21 -0
- data/lib/facts/sles/os/selinux/enabled.rb +21 -0
- data/lib/facts/sles/os/selinux/enforced.rb +21 -0
- data/lib/facts/sles/os/selinux/policy_version.rb +21 -0
- data/lib/facts/sles/puppet_version.rb +15 -0
- data/lib/facts/sles/ruby/platform.rb +3 -1
- data/lib/facts/sles/ruby/sitedir.rb +3 -1
- data/lib/facts/sles/ruby/version.rb +1 -0
- data/lib/facts/sles/sshalgorithmkey.rb +16 -0
- data/lib/facts/sles/sshfp_algorithm.rb +19 -0
- data/lib/facts/sles/system_uptime/days.rb +18 -0
- data/lib/facts/sles/system_uptime/hours.rb +18 -0
- data/lib/facts/sles/system_uptime/seconds.rb +18 -0
- data/lib/facts/sles/system_uptime/uptime.rb +18 -0
- data/lib/facts/solaris/augeas/version.rb +19 -0
- data/lib/facts/solaris/filesystems.rb +14 -0
- data/lib/facts/solaris/identity/user.rb +17 -0
- data/lib/facts/solaris/os/hardware.rb +3 -1
- data/lib/facts/solaris/puppet_version.rb +15 -0
- data/lib/facts/solaris/ruby/platform.rb +3 -1
- data/lib/facts/solaris/ruby/sitedir.rb +2 -1
- data/lib/facts/solaris/solaris_zones/current.rb +3 -1
- data/lib/facts/solaris/solaris_zones/zone.rb +39 -6
- data/lib/facts/solaris/ssh.rb +26 -0
- data/lib/facts/solaris/system_uptime/days.rb +17 -0
- data/lib/facts/solaris/system_uptime/hours.rb +17 -0
- data/lib/facts/{debian/system_uptime/minutes.rb → solaris/system_uptime/seconds.rb} +4 -4
- data/lib/facts/solaris/system_uptime/uptime.rb +17 -0
- data/lib/facts/solaris/timezone.rb +14 -0
- data/lib/facts/windows/augeas/version.rb +19 -0
- data/lib/facts/windows/puppet_version.rb +15 -0
- data/lib/facts_utils/bytes_converter.rb +15 -0
- data/lib/framework/config/block_list.rb +1 -1
- data/lib/framework/config/config_reader.rb +1 -1
- data/lib/framework/core/fact/external/external_fact_manager.rb +1 -1
- data/lib/framework/core/fact_loaders/external_fact_loader.rb +1 -1
- data/lib/framework/core/fact_manager.rb +5 -0
- data/lib/framework/logging/logger.rb +10 -1
- data/lib/models/fact_collection.rb +15 -1
- data/lib/models/resolved_fact.rb +5 -1
- data/lib/resolvers/aix/filesystem_resolver.rb +33 -0
- data/lib/resolvers/disk_resolver.rb +11 -3
- data/lib/resolvers/dmi_resolver.rb +1 -1
- data/lib/resolvers/filesystems_resolver.rb +2 -0
- data/lib/resolvers/fips_enabled_resolver.rb +2 -1
- data/lib/resolvers/hostname_resolver.rb +1 -1
- data/lib/resolvers/load_averages_resolver.rb +2 -0
- data/lib/resolvers/lsb_release_resolver.rb +23 -5
- data/lib/resolvers/macosx/ipaddress_resolver.rb +14 -1
- data/lib/resolvers/memory_resolver.rb +2 -0
- data/lib/resolvers/mountpoints_resolver.rb +2 -0
- data/lib/resolvers/networking_linux_resolver.rb +7 -1
- data/lib/resolvers/os_release_resolver.rb +1 -1
- data/lib/resolvers/processors_resolver.rb +2 -0
- data/lib/resolvers/puppet_version_resolver.rb +27 -0
- data/lib/resolvers/selinux_resolver.rb +36 -4
- data/lib/resolvers/solaris/filesystems_resolver.rb +32 -0
- data/lib/resolvers/solaris/zone_resolver.rb +4 -4
- data/lib/resolvers/ssh_resolver.rb +1 -1
- metadata +123 -8
- data/lib/facts/debian/os/distro.rb +0 -31
- data/lib/facts/debian/os/selinux.rb +0 -23
- data/lib/facts/el/os/selinux.rb +0 -23
- data/lib/facts/sles/os/selinux.rb +0 -23
data/lib/models/resolved_fact.rb
CHANGED
@@ -6,9 +6,13 @@ module Facter
|
|
6
6
|
attr_accessor :user_query, :filter_tokens, :value
|
7
7
|
|
8
8
|
def initialize(name, value = '', type = :core)
|
9
|
+
unless type =~ /core|legacy|custom/
|
10
|
+
raise ArgumentError, 'The type provided for fact is not legacy, core or custom!'
|
11
|
+
end
|
12
|
+
|
9
13
|
@name = name
|
10
14
|
@value = Utils.deep_stringify_keys(value)
|
11
|
-
|
15
|
+
@type = type
|
12
16
|
end
|
13
17
|
|
14
18
|
def legacy?
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
module Aix
|
6
|
+
class Filesystem < BaseResolver
|
7
|
+
@semaphore = Mutex.new
|
8
|
+
@fact_list ||= {}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
private
|
12
|
+
|
13
|
+
def post_resolve(fact_name)
|
14
|
+
@fact_list.fetch(fact_name) { read_vtf_file(fact_name) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def read_vtf_file(fact_name)
|
18
|
+
return unless File.readable?('/etc/vfs')
|
19
|
+
|
20
|
+
file_content = File.readlines('/etc/vfs').map do |line|
|
21
|
+
next if line =~ /#|%/ # skip lines that are comments or defaultvfs line
|
22
|
+
|
23
|
+
line.split(' ').first
|
24
|
+
end
|
25
|
+
|
26
|
+
@fact_list[:file_systems] = file_content.compact.sort.join(',')
|
27
|
+
@fact_list[fact_name]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -17,28 +17,36 @@ module Facter
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def read_facts(fact_name)
|
20
|
-
@fact_list[:disks] = {}
|
21
20
|
build_disks_hash
|
22
21
|
|
23
22
|
FILE_PATHS.each do |key, file|
|
24
23
|
@fact_list[:disks].each do |disk, value|
|
25
24
|
file_path = File.join(DIR, disk, file)
|
26
25
|
|
27
|
-
next unless File.
|
26
|
+
next unless File.readable?(file_path)
|
28
27
|
|
29
28
|
result = File.read(file_path).strip
|
30
29
|
|
31
30
|
# Linux always considers sectors to be 512 bytes long independently of the devices real block size.
|
32
|
-
value[key] = file =~ /size/ ? result
|
31
|
+
value[key] = file =~ /size/ ? construct_size(value, result) : result
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
35
|
+
@fact_list[:disks] = nil if @fact_list[:disks].empty?
|
36
36
|
@fact_list[fact_name]
|
37
37
|
end
|
38
38
|
|
39
39
|
def build_disks_hash
|
40
|
+
@fact_list[:disks] = {}
|
40
41
|
directories = Dir.entries(DIR).reject { |dir| dir =~ /\.+/ }
|
41
42
|
directories.each { |disk| @fact_list[:disks].merge!(disk => {}) }
|
43
|
+
@fact_list[:disks].select! { |disk, _fact| File.readable?(File.join(DIR, disk, 'device')) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def construct_size(facts, value)
|
47
|
+
value = value.to_i * 512
|
48
|
+
facts[:size_bytes] = value
|
49
|
+
facts[:size] = Facter::BytesToHumanReadable.convert(value)
|
42
50
|
end
|
43
51
|
end
|
44
52
|
end
|
@@ -35,7 +35,7 @@ module Facter
|
|
35
35
|
product_uuid]
|
36
36
|
return unless File.directory?('/sys/class/dmi')
|
37
37
|
|
38
|
-
if files.include?(fact_name.to_s) && File.
|
38
|
+
if files.include?(fact_name.to_s) && File.readable?("/sys/class/dmi/id/#{fact_name}")
|
39
39
|
@fact_list[fact_name] = File.read("/sys/class/dmi/id/#{fact_name}").strip
|
40
40
|
chassis_to_name(@fact_list[fact_name]) if fact_name == :chassis_type
|
41
41
|
|
@@ -16,7 +16,8 @@ module Facter
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def read_fips_file(fact_name)
|
19
|
-
return @fact_list[fact_name] = false unless File.directory?('/proc/sys/crypto')
|
19
|
+
return @fact_list[fact_name] = false unless File.directory?('/proc/sys/crypto') ||
|
20
|
+
File.readable?('/proc/sys/crypto/fips_enabled')
|
20
21
|
|
21
22
|
file_output = File.read('/proc/sys/crypto/fips_enabled')
|
22
23
|
@fact_list[:fips_enabled] = file_output.strip == '1'
|
@@ -30,7 +30,7 @@ module Facter
|
|
30
30
|
def read_domain(output)
|
31
31
|
if output =~ /.*?\.(.+$)/
|
32
32
|
domain = Regexp.last_match(1)
|
33
|
-
elsif File.
|
33
|
+
elsif File.readable?('/etc/resolv.conf')
|
34
34
|
file = File.read('/etc/resolv.conf')
|
35
35
|
if file =~ /^search\s+(\S+)/
|
36
36
|
domain = Regexp.last_match(1)
|
@@ -15,6 +15,8 @@ module Facter
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def read_load_averages_file(fact_name)
|
18
|
+
return unless File.readable?('/proc/loadavg')
|
19
|
+
|
18
20
|
output = File.read('/proc/loadavg')
|
19
21
|
@fact_list[:load_averages] = {}.tap { |h| h['1m'], h['5m'], h['15m'], = output.split.map(&:to_f) }
|
20
22
|
|
@@ -3,30 +3,48 @@
|
|
3
3
|
module Facter
|
4
4
|
module Resolvers
|
5
5
|
class LsbRelease < BaseResolver
|
6
|
+
# :lsb_version
|
6
7
|
# :distributor_id
|
7
8
|
# :description
|
8
9
|
# :release
|
9
10
|
# :codename
|
10
11
|
|
11
12
|
@semaphore = Mutex.new
|
13
|
+
@log = Facter::Log.new(self)
|
12
14
|
@fact_list ||= {}
|
13
15
|
|
14
16
|
class << self
|
15
17
|
private
|
16
18
|
|
17
19
|
def post_resolve(fact_name)
|
18
|
-
@fact_list.fetch(fact_name) {
|
20
|
+
@fact_list.fetch(fact_name) { retrieve_facts(fact_name) }
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
23
|
+
def retrieve_facts(fact_name)
|
24
|
+
lsb_release_installed? if @fact_list[:lsb_release_installed].nil?
|
25
|
+
read_lsb_release_file if @fact_list[:lsb_release_installed]
|
26
|
+
@fact_list[fact_name]
|
27
|
+
end
|
28
|
+
|
29
|
+
def lsb_release_installed?
|
30
|
+
output, stderr, _status = Open3.capture3('which lsb_release')
|
31
|
+
@log.debug(stderr) unless stderr.empty?
|
32
|
+
@fact_list[:lsb_release_installed] = !output.empty?
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_lsb_release_file
|
36
|
+
output, stderr, _status = Open3.capture3('lsb_release -a')
|
37
|
+
@log.debug(stderr) unless stderr.empty?
|
38
|
+
build_fact_list(output)
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_fact_list(info)
|
42
|
+
release_info = info.delete("\t").split("\n").map { |e| e.split(':', 2) }
|
24
43
|
|
25
44
|
result = Hash[*release_info.flatten]
|
26
45
|
result.each { |k, v| @fact_list[k.downcase.gsub(/\s/, '_').to_sym] = v }
|
27
46
|
|
28
47
|
@fact_list[:identifier] = @fact_list[:distributor_id]
|
29
|
-
@fact_list[fact_name]
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
@@ -18,10 +18,12 @@ module Facter
|
|
18
18
|
ip = nil
|
19
19
|
primary_interface = read_primary_interface
|
20
20
|
unless primary_interface.nil?
|
21
|
+
@fact_list[:primary] = primary_interface
|
21
22
|
output, _status = Open3.capture2("ipconfig getifaddr #{primary_interface}")
|
22
23
|
ip = output.strip
|
23
24
|
end
|
24
|
-
|
25
|
+
find_all_interfaces
|
26
|
+
@fact_list[:ip] = ip
|
25
27
|
@fact_list[fact_name]
|
26
28
|
end
|
27
29
|
|
@@ -33,6 +35,17 @@ module Facter
|
|
33
35
|
end
|
34
36
|
iface
|
35
37
|
end
|
38
|
+
|
39
|
+
def find_all_interfaces
|
40
|
+
output, _status = Open3.capture2('ifconfig -a 2>/dev/null')
|
41
|
+
|
42
|
+
data_hash = Hash[*output.split(/^([A-Za-z0-9_]+): /)[1..-1]]
|
43
|
+
|
44
|
+
macaddress = */ether (([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}))/.match(data_hash[@fact_list[:primary]])
|
45
|
+
@fact_list[:macaddress] = macaddress[1]
|
46
|
+
|
47
|
+
@fact_list[:interfaces] = data_hash.keys.join(',')
|
48
|
+
end
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
@@ -19,10 +19,16 @@ module Facter
|
|
19
19
|
|
20
20
|
retrieve_default_interface_and_ip
|
21
21
|
retrieve_interface_info
|
22
|
-
|
22
|
+
retrieve_macaddress
|
23
23
|
@fact_list[fact_name]
|
24
24
|
end
|
25
25
|
|
26
|
+
def retrieve_macaddress
|
27
|
+
output, _status = Open3.capture2("ip link show #{@fact_list[:primary_interface]}")
|
28
|
+
macaddress = */ether ([^ ]*) /.match(output)
|
29
|
+
@fact_list[:macaddress] = macaddress[1]
|
30
|
+
end
|
31
|
+
|
26
32
|
def retrieve_interface_info
|
27
33
|
output, _status = Open3.capture2('ip -o address')
|
28
34
|
interfaces = {}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
class PuppetVersionResolver < BaseResolver
|
6
|
+
# :puppetversion
|
7
|
+
|
8
|
+
@semaphore = Mutex.new
|
9
|
+
@fact_list ||= {}
|
10
|
+
|
11
|
+
class << self
|
12
|
+
private
|
13
|
+
|
14
|
+
def post_resolve(fact_name)
|
15
|
+
@fact_list.fetch(fact_name) { puppet_version(fact_name) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def puppet_version(fact_name)
|
19
|
+
require 'puppet/version'
|
20
|
+
@fact_list[:puppetversion] = Puppet.version
|
21
|
+
|
22
|
+
@fact_list[fact_name]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -14,22 +14,54 @@ module Facter
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def post_resolve(fact_name)
|
17
|
-
@fact_list.fetch(fact_name) {
|
17
|
+
@fact_list.fetch(fact_name) { retrieve_facts(fact_name) }
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def retrieve_facts(fact_name)
|
21
|
+
mountpoint = read_mounts_file if @fact_list[:enabled].nil?
|
22
|
+
read_other_selinux_facts(mountpoint) if @fact_list[:enabled] && File.readable?('/etc/selinux/config')
|
23
|
+
|
24
|
+
@fact_list[fact_name]
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_mounts_file
|
21
28
|
output, _s = Open3.capture2('cat /proc/self/mounts')
|
22
29
|
@fact_list[:enabled] = false
|
30
|
+
mountpoint = ''
|
23
31
|
|
24
32
|
output.each_line do |line|
|
25
33
|
next unless line =~ /selinuxfs/
|
26
34
|
|
27
35
|
@fact_list[:enabled] = true
|
28
|
-
|
36
|
+
mountpoint = line.split("\s")[1]
|
29
37
|
break
|
30
38
|
end
|
39
|
+
mountpoint
|
40
|
+
end
|
31
41
|
|
32
|
-
|
42
|
+
def read_other_selinux_facts(mountpoint)
|
43
|
+
read_selinux_config
|
44
|
+
|
45
|
+
enforce_file = "#{mountpoint}/enforce"
|
46
|
+
policy_file = "#{mountpoint}/policyvers"
|
47
|
+
|
48
|
+
@fact_list[:policy_version] = File.read(policy_file) if File.readable?(policy_file)
|
49
|
+
|
50
|
+
enforce = File.read(enforce_file) if File.readable?(enforce_file)
|
51
|
+
if enforce.eql?('1')
|
52
|
+
@fact_list[:enforced] = true
|
53
|
+
@fact_list[:current_mode] = 'enforcing'
|
54
|
+
else
|
55
|
+
@fact_list[:enforced] = false
|
56
|
+
@fact_list[:current_mode] = 'permissive'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def read_selinux_config
|
61
|
+
File.readlines('/etc/selinux/config').map do |line|
|
62
|
+
@fact_list[:config_mode] = line.split('=').last.strip if line =~ /^SELINUX=/
|
63
|
+
@fact_list[:config_policy] = line.split('=').last.strip if line =~ /^SELINUXTYPE=/
|
64
|
+
end
|
33
65
|
end
|
34
66
|
end
|
35
67
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Facter
|
4
|
+
module Resolvers
|
5
|
+
module Solaris
|
6
|
+
class Filesystem < BaseResolver
|
7
|
+
@semaphore = Mutex.new
|
8
|
+
@fact_list ||= {}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
private
|
12
|
+
|
13
|
+
def post_resolve(fact_name)
|
14
|
+
@fact_list.fetch(fact_name) { read_sysdef_file(fact_name) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def read_sysdef_file(fact_name)
|
18
|
+
return unless File.readable?('/usr/sbin/sysdef')
|
19
|
+
|
20
|
+
file_content, _status = Open3.capture2('/usr/sbin/sysdef')
|
21
|
+
files = file_content.split("\n").map do |line|
|
22
|
+
line.split('/').last if line =~ /^fs\.*/
|
23
|
+
end
|
24
|
+
|
25
|
+
@fact_list[:file_systems] = files.compact.sort.join(',')
|
26
|
+
@fact_list[fact_name]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -14,7 +14,8 @@ module Facter
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def build_zone_fact(fact_name)
|
17
|
-
|
17
|
+
command = '/usr/sbin/zoneadm list -cp'
|
18
|
+
zone_adm_output, status = Open3.capture2(command)
|
18
19
|
unless status.to_s.include?('exit 0')
|
19
20
|
@log.debug("Command #{command} returned status: #{status}")
|
20
21
|
return
|
@@ -32,17 +33,16 @@ module Facter
|
|
32
33
|
zones_fact = []
|
33
34
|
zones_result.each_line do |zone_line|
|
34
35
|
id, name, status, path, uuid, brand, ip_type = zone_line.split(':')
|
35
|
-
|
36
|
+
zones_fact << {
|
36
37
|
brand: brand,
|
37
38
|
id: id,
|
38
|
-
|
39
|
+
iptype: ip_type.chomp,
|
39
40
|
name: name,
|
40
41
|
uuid: uuid,
|
41
42
|
status: status,
|
42
43
|
path: path
|
43
44
|
|
44
45
|
}
|
45
|
-
zones_fact << zone_fact
|
46
46
|
end
|
47
47
|
zones_fact
|
48
48
|
end
|
@@ -24,7 +24,7 @@ module Facter
|
|
24
24
|
next unless File.directory?(file_path)
|
25
25
|
|
26
26
|
@file_names.each do |file_name|
|
27
|
-
next unless
|
27
|
+
next unless FileTest.file?(File.join(file_path, file_name))
|
28
28
|
|
29
29
|
key_type, key = File.read(File.join(file_path, file_name)).split(' ')
|
30
30
|
key_name = determine_ssh_key_name(key_type)
|