facter 1.7.6 → 2.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/COMMITTERS.md +194 -0
- data/CONTRIBUTING.md +63 -235
- data/Gemfile +12 -8
- data/README.md +1 -2
- data/Rakefile +1 -1
- data/bin/facter +0 -4
- data/ext/build_defaults.yaml +2 -2
- data/ext/project_data.yaml +18 -0
- data/install.rb +1 -16
- data/lib/facter.rb +171 -171
- data/lib/facter/application.rb +65 -54
- data/lib/facter/core/aggregate.rb +220 -0
- data/lib/facter/core/directed_graph.rb +46 -0
- data/lib/facter/core/execution.rb +100 -0
- data/lib/facter/core/execution/base.rb +73 -0
- data/lib/facter/core/execution/posix.rb +50 -0
- data/lib/facter/core/execution/windows.rb +57 -0
- data/lib/facter/core/logging.rb +169 -0
- data/lib/facter/core/resolvable.rb +94 -0
- data/lib/facter/core/suitable.rb +117 -0
- data/lib/facter/domain.rb +15 -9
- data/lib/facter/filesystems.rb +1 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/hostname.rb +3 -3
- data/lib/facter/interfaces.rb +6 -1
- data/lib/facter/ipaddress.rb +2 -2
- data/lib/facter/kernel.rb +1 -1
- data/lib/facter/kernelrelease.rb +1 -1
- data/lib/facter/ldom.rb +1 -1
- data/lib/facter/lsbdistcodename.rb +1 -1
- data/lib/facter/lsbdistdescription.rb +1 -1
- data/lib/facter/lsbdistid.rb +1 -1
- data/lib/facter/lsbdistrelease.rb +1 -1
- data/lib/facter/lsbrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -14
- data/lib/facter/macosx.rb +2 -2
- data/lib/facter/memory.rb +8 -19
- data/lib/facter/operatingsystem.rb +1 -1
- data/lib/facter/operatingsystemrelease.rb +34 -1
- data/lib/facter/physicalprocessorcount.rb +6 -6
- data/lib/facter/processor.rb +11 -10
- data/lib/facter/selinux.rb +4 -15
- data/lib/facter/ssh.rb +5 -2
- data/lib/facter/util/architecture.rb +2 -2
- data/lib/facter/util/collection.rb +42 -38
- data/lib/facter/util/config.rb +19 -9
- data/lib/facter/util/confine.rb +34 -4
- data/lib/facter/util/ec2.rb +1 -1
- data/lib/facter/util/fact.rb +108 -36
- data/lib/facter/util/file_read.rb +7 -6
- data/lib/facter/util/formatter.rb +38 -0
- data/lib/facter/util/ip.rb +3 -3
- data/lib/facter/util/loader.rb +62 -42
- data/lib/facter/util/macosx.rb +7 -8
- data/lib/facter/util/manufacturer.rb +3 -3
- data/lib/facter/util/memory.rb +13 -13
- data/lib/facter/util/monkey_patches.rb +0 -31
- data/lib/facter/util/netmask.rb +3 -3
- data/lib/facter/util/normalization.rb +94 -0
- data/lib/facter/util/nothing_loader.rb +3 -6
- data/lib/facter/util/parser.rb +3 -5
- data/lib/facter/util/plist/generator.rb +1 -1
- data/lib/facter/util/processor.rb +15 -15
- data/lib/facter/util/resolution.rb +112 -289
- data/lib/facter/util/solaris_zones.rb +4 -4
- data/lib/facter/util/uptime.rb +8 -3
- data/lib/facter/util/values.rb +67 -1
- data/lib/facter/util/virtual.rb +10 -10
- data/lib/facter/util/xendomains.rb +1 -1
- data/lib/facter/version.rb +42 -39
- data/lib/facter/virtual.rb +6 -7
- data/lib/facter/zfs_version.rb +3 -3
- data/lib/facter/zpool_version.rb +3 -3
- data/spec/fixtures/unit/netmask/darwin_10_8_5.txt +30 -0
- data/spec/unit/application_spec.rb +46 -1
- data/spec/unit/core/aggregate_spec.rb +125 -0
- data/spec/unit/core/directed_graph_spec.rb +79 -0
- data/spec/unit/core/execution/base_spec.rb +119 -0
- data/spec/unit/core/execution/posix_spec.rb +86 -0
- data/spec/unit/core/execution/windows_spec.rb +106 -0
- data/spec/unit/core/execution_spec.rb +37 -0
- data/spec/unit/core/logging_spec.rb +104 -0
- data/spec/unit/core/resolvable_spec.rb +81 -0
- data/spec/unit/core/suitable_spec.rb +96 -0
- data/spec/unit/domain_spec.rb +5 -5
- data/spec/unit/facter_spec.rb +61 -222
- data/spec/unit/filesystems_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +5 -5
- data/spec/unit/hardwaremodel_spec.rb +1 -1
- data/spec/unit/hostname_spec.rb +4 -4
- data/spec/unit/id_spec.rb +3 -3
- data/spec/unit/interfaces_spec.rb +10 -0
- data/spec/unit/ipaddress6_spec.rb +4 -4
- data/spec/unit/ipaddress_spec.rb +1 -1
- data/spec/unit/kernel_spec.rb +2 -2
- data/spec/unit/kernelmajversion_spec.rb +1 -1
- data/spec/unit/kernelrelease_spec.rb +4 -4
- data/spec/unit/kernelversion_spec.rb +2 -2
- data/spec/unit/ldom_spec.rb +2 -2
- data/spec/unit/lsbdistcodename_spec.rb +2 -2
- data/spec/unit/lsbdistdescription_spec.rb +2 -2
- data/spec/unit/lsbdistid_spec.rb +2 -2
- data/spec/unit/lsbdistrelease_spec.rb +2 -2
- data/spec/unit/lsbrelease_spec.rb +2 -2
- data/spec/unit/manufacturer_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +24 -31
- data/spec/unit/netmask_spec.rb +9 -0
- data/spec/unit/operatingsystem_spec.rb +1 -1
- data/spec/unit/operatingsystemrelease_spec.rb +62 -4
- data/spec/unit/physicalprocessorcount_spec.rb +10 -10
- data/spec/unit/processor_spec.rb +11 -11
- data/spec/unit/selinux_spec.rb +2 -8
- data/spec/unit/ssh_spec.rb +3 -2
- data/spec/unit/uniqueid_spec.rb +3 -3
- data/spec/unit/util/collection_spec.rb +37 -35
- data/spec/unit/util/config_spec.rb +20 -0
- data/spec/unit/util/confine_spec.rb +21 -0
- data/spec/unit/util/directory_loader_spec.rb +1 -0
- data/spec/unit/util/ec2_spec.rb +6 -6
- data/spec/unit/util/fact_spec.rb +92 -90
- data/spec/unit/util/ip_spec.rb +2 -2
- data/spec/unit/util/loader_spec.rb +127 -186
- data/spec/unit/util/macaddress_spec.rb +2 -2
- data/spec/unit/util/macosx_spec.rb +8 -8
- data/spec/unit/util/manufacturer_spec.rb +3 -3
- data/spec/unit/util/normalization_spec.rb +113 -0
- data/spec/unit/util/parser_spec.rb +25 -3
- data/spec/unit/util/processor_spec.rb +2 -2
- data/spec/unit/util/resolution_spec.rb +60 -631
- data/spec/unit/util/solaris_zones_spec.rb +5 -5
- data/spec/unit/util/uptime_spec.rb +1 -1
- data/spec/unit/util/values_spec.rb +131 -0
- data/spec/unit/util/virtual_spec.rb +16 -16
- data/spec/unit/util/xendomains_spec.rb +2 -2
- data/spec/unit/virtual_spec.rb +39 -39
- data/spec/unit/zfs_version_spec.rb +11 -11
- data/spec/unit/zonename_spec.rb +2 -2
- data/spec/unit/zones_spec.rb +1 -1
- data/spec/unit/zpool_version_spec.rb +11 -11
- metadata +466 -447
- data/lib/facter/util/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/LICENSE +0 -19
- data/lib/facter/util/cfpropertylist/README +0 -44
- data/lib/facter/util/cfpropertylist/Rakefile +0 -44
- data/lib/facter/util/cfpropertylist/THANKS +0 -7
- data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +0 -6
- data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +0 -562
- data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +0 -26
- data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +0 -407
- data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +0 -244
- data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +0 -135
- data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +0 -140
- data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +0 -136
- data/spec/unit/util/monkey_patches_spec.rb +0 -42
data/lib/facter/macosx.rb
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
# at this point in time.
|
25
25
|
# In particular, Installed Software might be an interesting addition.
|
26
26
|
|
27
|
-
require 'facter/util/macosx'
|
28
|
-
|
29
27
|
if Facter.value(:kernel) == "Darwin"
|
28
|
+
require 'facter/util/macosx'
|
29
|
+
|
30
30
|
Facter::Util::Macosx.hardware_overview.each do |fact, value|
|
31
31
|
Facter.add("sp_#{fact}") do
|
32
32
|
confine :kernel => :darwin
|
data/lib/facter/memory.rb
CHANGED
@@ -86,7 +86,7 @@ if Facter.value(:kernel) == "Darwin"
|
|
86
86
|
Facter.add("SwapEncrypted") do
|
87
87
|
confine :kernel => :Darwin
|
88
88
|
setcode do
|
89
|
-
swap = Facter::
|
89
|
+
swap = Facter::Core::Execution.exec('sysctl vm.swapusage')
|
90
90
|
encrypted = false
|
91
91
|
if swap =~ /\(encrypted\)/ then encrypted = true; end
|
92
92
|
encrypted
|
@@ -99,7 +99,7 @@ if Facter.value(:kernel) == "SunOS"
|
|
99
99
|
Facter.add("memorysize_mb") do
|
100
100
|
confine :kernel => :sunos
|
101
101
|
# Total memory size available from prtconf
|
102
|
-
pconf = Facter::
|
102
|
+
pconf = Facter::Core::Execution.exec('/usr/sbin/prtconf 2>/dev/null')
|
103
103
|
phymem = ""
|
104
104
|
pconf.each_line do |line|
|
105
105
|
if line =~ /^Memory size:\s+(\d+) Megabytes/
|
@@ -143,8 +143,8 @@ end
|
|
143
143
|
Facter.add("swapsize_mb") do
|
144
144
|
confine :kernel => :dragonfly
|
145
145
|
setcode do
|
146
|
-
page_size = Facter::
|
147
|
-
swaptotal = Facter::
|
146
|
+
page_size = Facter::Core::Execution.exec("/sbin/sysctl -n hw.pagesize").to_f
|
147
|
+
swaptotal = Facter::Core::Execution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size
|
148
148
|
"%.2f" % [(swaptotal.to_f / 1024.0) / 1024.0]
|
149
149
|
end
|
150
150
|
end
|
@@ -152,22 +152,11 @@ end
|
|
152
152
|
Facter.add("swapfree_mb") do
|
153
153
|
confine :kernel => :dragonfly
|
154
154
|
setcode do
|
155
|
-
page_size = Facter::
|
156
|
-
swaptotal = Facter::
|
157
|
-
swap_anon_use = Facter::
|
158
|
-
swap_cache_use = Facter::
|
155
|
+
page_size = Facter::Core::Execution.exec("/sbin/sysctl -n hw.pagesize").to_f
|
156
|
+
swaptotal = Facter::Core::Execution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size
|
157
|
+
swap_anon_use = Facter::Core::Execution.exec("/sbin/sysctl -n vm.swap_anon_use").to_f * page_size
|
158
|
+
swap_cache_use = Facter::Core::Execution.exec("/sbin/sysctl -n vm.swap_cache_use").to_f * page_size
|
159
159
|
swapfree = swaptotal - swap_anon_use - swap_cache_use
|
160
160
|
"%.2f" % [(swapfree.to_f / 1024.0) / 1024.0]
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
164
|
-
# http://projects.puppetlabs.com/issues/11436
|
165
|
-
#
|
166
|
-
# Unifying naming for the amount of physical memory in a given host.
|
167
|
-
# This fact is DEPRECATED and will be removed in Facter 2.0 per
|
168
|
-
# http://projects.puppetlabs.com/issues/11466
|
169
|
-
Facter.add("MemoryTotal") do
|
170
|
-
setcode do
|
171
|
-
Facter.value("memorysize")
|
172
|
-
end
|
173
|
-
end
|
@@ -16,7 +16,7 @@ Facter.add(:operatingsystem) do
|
|
16
16
|
setcode do
|
17
17
|
# Use uname -v because /etc/release can change in zones under SmartOS.
|
18
18
|
# It's apparently not trustworthy enough to rely on for this fact.
|
19
|
-
output = Facter::
|
19
|
+
output = Facter::Core::Execution.exec('uname -v')
|
20
20
|
if output =~ /^joyent_/
|
21
21
|
"SmartOS"
|
22
22
|
elsif output =~ /^oi_/
|
@@ -141,7 +141,7 @@ end
|
|
141
141
|
Facter.add(:operatingsystemrelease) do
|
142
142
|
confine :operatingsystem => %w{VMwareESX}
|
143
143
|
setcode do
|
144
|
-
release = Facter::
|
144
|
+
release = Facter::Core::Execution.exec('vmware -v')
|
145
145
|
if match = /VMware ESX .*?(\d.*)/.match(release)
|
146
146
|
match[1]
|
147
147
|
end
|
@@ -188,6 +188,39 @@ Facter.add(:operatingsystemrelease) do
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
+
Facter.add(:operatingsystemrelease) do
|
192
|
+
confine :operatingsystem => :windows
|
193
|
+
setcode do
|
194
|
+
require 'facter/util/wmi'
|
195
|
+
result = nil
|
196
|
+
Facter::Util::WMI.execquery("SELECT version, producttype FROM Win32_OperatingSystem").each do |os|
|
197
|
+
result =
|
198
|
+
case os.version
|
199
|
+
when /^6\.2/
|
200
|
+
os.producttype == 1 ? "8" : "2012"
|
201
|
+
when /^6\.1/
|
202
|
+
os.producttype == 1 ? "7" : "2008 R2"
|
203
|
+
when /^6\.0/
|
204
|
+
os.producttype == 1 ? "Vista" : "2008"
|
205
|
+
when /^5\.2/
|
206
|
+
if os.producttype == 1
|
207
|
+
"XP"
|
208
|
+
else
|
209
|
+
begin
|
210
|
+
os.othertypedescription == "R2" ? "2003 R2" : "2003"
|
211
|
+
rescue NoMethodError
|
212
|
+
"2003"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
else
|
216
|
+
Facter[:kernelrelease].value
|
217
|
+
end
|
218
|
+
break
|
219
|
+
end
|
220
|
+
result
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
191
224
|
Facter.add(:operatingsystemrelease) do
|
192
225
|
setcode do Facter[:kernelrelease].value end
|
193
226
|
end
|
@@ -39,7 +39,7 @@ Facter.add('physicalprocessorcount') do
|
|
39
39
|
lookup_pattern = "#{sysfs_cpu_directory}" +
|
40
40
|
"/cpu*/topology/physical_package_id"
|
41
41
|
|
42
|
-
Dir.glob(lookup_pattern).collect { |f| Facter::
|
42
|
+
Dir.glob(lookup_pattern).collect { |f| Facter::Core::Execution.exec("cat #{f}")}.uniq.size.to_s
|
43
43
|
|
44
44
|
else
|
45
45
|
#
|
@@ -48,9 +48,9 @@ Facter.add('physicalprocessorcount') do
|
|
48
48
|
# We assume that /proc/cpuinfo has what we need and is so then we need
|
49
49
|
# to make sure that we only count unique entries ...
|
50
50
|
#
|
51
|
-
str = Facter::
|
51
|
+
str = Facter::Core::Execution.exec("grep 'physical.\\+:' /proc/cpuinfo")
|
52
52
|
|
53
|
-
if str then str.scan(/\d+/).uniq.size; end
|
53
|
+
if str then str.scan(/\d+/).uniq.size.to_s; end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -59,7 +59,7 @@ Facter.add('physicalprocessorcount') do
|
|
59
59
|
confine :kernel => :windows
|
60
60
|
setcode do
|
61
61
|
require 'facter/util/wmi'
|
62
|
-
Facter::Util::WMI.execquery("select Name from Win32_Processor").Count
|
62
|
+
Facter::Util::WMI.execquery("select Name from Win32_Processor").Count.to_s
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -75,9 +75,9 @@ Facter.add('physicalprocessorcount') do
|
|
75
75
|
cmd = "/usr/sbin/psrinfo"
|
76
76
|
result = nil
|
77
77
|
if (major_version > 5) or (major_version == 5 and minor_version >= 8) then
|
78
|
-
result = Facter::
|
78
|
+
result = Facter::Core::Execution.exec("#{cmd} -p")
|
79
79
|
else
|
80
|
-
output = Facter::
|
80
|
+
output = Facter::Core::Execution.exec(cmd)
|
81
81
|
result = output.split("\n").length.to_s
|
82
82
|
end
|
83
83
|
end
|
data/lib/facter/processor.rb
CHANGED
@@ -22,8 +22,9 @@
|
|
22
22
|
require 'thread'
|
23
23
|
require 'facter/util/processor'
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
# We have to enumerate these outside a Facter.add block to get the processorN
|
26
|
+
# descriptions iteratively (but we need them inside the Facter.add block above
|
27
|
+
# for tests on processorcount to work)
|
27
28
|
processor_list = case Facter::Util::Processor.kernel_fact_value
|
28
29
|
when "AIX"
|
29
30
|
Facter::Util::Processor.aix_processor_list
|
@@ -90,21 +91,21 @@ end
|
|
90
91
|
Facter.add("Processor") do
|
91
92
|
confine :kernel => :openbsd
|
92
93
|
setcode do
|
93
|
-
Facter::
|
94
|
+
Facter::Core::Execution.exec("uname -p")
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
97
98
|
Facter.add("ProcessorCount") do
|
98
99
|
confine :kernel => :openbsd
|
99
100
|
setcode do
|
100
|
-
Facter::
|
101
|
+
Facter::Core::Execution.exec("sysctl -n hw.ncpu")
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
Facter.add("ProcessorCount") do
|
105
106
|
confine :kernel => :Darwin
|
106
107
|
setcode do
|
107
|
-
Facter::
|
108
|
+
Facter::Core::Execution.exec("sysctl -n hw.ncpu")
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
@@ -149,14 +150,14 @@ end
|
|
149
150
|
Facter.add("Processor") do
|
150
151
|
confine :kernel => [:dragonfly,:freebsd]
|
151
152
|
setcode do
|
152
|
-
Facter::
|
153
|
+
Facter::Core::Execution.exec("sysctl -n hw.model")
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
156
157
|
Facter.add("ProcessorCount") do
|
157
158
|
confine :kernel => [:dragonfly,:freebsd]
|
158
159
|
setcode do
|
159
|
-
Facter::
|
160
|
+
Facter::Core::Execution.exec("sysctl -n hw.ncpu")
|
160
161
|
end
|
161
162
|
end
|
162
163
|
|
@@ -168,15 +169,15 @@ Facter.add("ProcessorCount") do
|
|
168
169
|
result = nil
|
169
170
|
|
170
171
|
if (major_version > 5) or (major_version == 5 and minor_version >= 8) then
|
171
|
-
if kstat = Facter::
|
172
|
+
if kstat = Facter::Core::Execution.exec("/usr/bin/kstat cpu_info")
|
172
173
|
result = kstat.scan(/\bcore_id\b\s+\d+/).uniq.length
|
173
174
|
end
|
174
175
|
else
|
175
|
-
if output = Facter::
|
176
|
+
if output = Facter::Core::Execution.exec("/usr/sbin/psrinfo") then
|
176
177
|
result = output.split("\n").length
|
177
178
|
end
|
178
179
|
end
|
179
180
|
|
180
|
-
result
|
181
|
+
result.to_s
|
181
182
|
end
|
182
183
|
end
|
data/lib/facter/selinux.rb
CHANGED
@@ -22,7 +22,7 @@ def selinux_mount_point
|
|
22
22
|
# a hang. Reading from other parts of /proc does not seem to cause this problem.
|
23
23
|
# The work around is to read the file in another process.
|
24
24
|
# -- andy Fri Aug 31 2012
|
25
|
-
selinux_line = Facter::
|
25
|
+
selinux_line = Facter::Core::Execution.exec('cat /proc/self/mounts').each_line.find { |line| line =~ /selinuxfs/ }
|
26
26
|
if selinux_line
|
27
27
|
path = selinux_line.split[1]
|
28
28
|
end
|
@@ -72,7 +72,7 @@ Facter.add("selinux_current_mode") do
|
|
72
72
|
confine :selinux => :true
|
73
73
|
setcode do
|
74
74
|
result = 'unknown'
|
75
|
-
mode = Facter::
|
75
|
+
mode = Facter::Core::Execution.exec(sestatus_cmd)
|
76
76
|
mode.each_line { |l| result = $1 if l =~ /^Current mode\:\s+(\w+)$/i }
|
77
77
|
result.chomp
|
78
78
|
end
|
@@ -82,7 +82,7 @@ Facter.add("selinux_config_mode") do
|
|
82
82
|
confine :selinux => :true
|
83
83
|
setcode do
|
84
84
|
result = 'unknown'
|
85
|
-
mode = Facter::
|
85
|
+
mode = Facter::Core::Execution.exec(sestatus_cmd)
|
86
86
|
mode.each_line { |l| result = $1 if l =~ /^Mode from config file\:\s+(\w+)$/i }
|
87
87
|
result.chomp
|
88
88
|
end
|
@@ -92,19 +92,8 @@ Facter.add("selinux_config_policy") do
|
|
92
92
|
confine :selinux => :true
|
93
93
|
setcode do
|
94
94
|
result = 'unknown'
|
95
|
-
mode = Facter::
|
95
|
+
mode = Facter::Core::Execution.exec(sestatus_cmd)
|
96
96
|
mode.each_line { |l| result = $1 if l =~ /^Policy from config file\:\s+(\w+)$/i }
|
97
97
|
result.chomp
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
101
|
-
# This is a legacy fact which returns the old selinux_mode fact value to prevent
|
102
|
-
# breakages of existing manifests. It should be removed at the next major release.
|
103
|
-
# See ticket #6677.
|
104
|
-
|
105
|
-
Facter.add("selinux_mode") do
|
106
|
-
confine :selinux => :true
|
107
|
-
setcode do
|
108
|
-
Facter.value(:selinux_config_policy)
|
109
|
-
end
|
110
|
-
end
|
data/lib/facter/ssh.rb
CHANGED
@@ -11,8 +11,11 @@
|
|
11
11
|
## Facts related to SSH
|
12
12
|
##
|
13
13
|
|
14
|
-
{"SSHDSAKey" => { :file => "ssh_host_dsa_key.pub", :sshfprrtype => 2 }
|
15
|
-
|
14
|
+
{"SSHDSAKey" => { :file => "ssh_host_dsa_key.pub", :sshfprrtype => 2 },
|
15
|
+
"SSHRSAKey" => { :file => "ssh_host_rsa_key.pub", :sshfprrtype => 1 },
|
16
|
+
"SSHECDSAKey" => { :file => "ssh_host_ecdsa_key.pub", :sshfprrtype => 3 },
|
17
|
+
"SSHED25519Key" => { :file => "ssh_host_ed25519_key.pub", :sshfprrtype => 4 } }.each do |name,key|
|
18
|
+
|
16
19
|
Facter.add(name) do
|
17
20
|
setcode do
|
18
21
|
value = nil
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
module Facter::Util::Architecture
|
4
4
|
##
|
5
|
-
# lsattr is intended to directly delegate to Facter::
|
5
|
+
# lsattr is intended to directly delegate to Facter::Core::Execution.exec in
|
6
6
|
# an effort to make the processorX facts easier to test. See also the
|
7
7
|
# {lsdev} method.
|
8
8
|
def self.lsattr(command="lsattr -El proc0 -a type")
|
9
|
-
Facter::
|
9
|
+
Facter::Core::Execution.exec(command)
|
10
10
|
end
|
11
11
|
|
12
12
|
##
|
@@ -4,6 +4,8 @@ require 'facter/util/loader'
|
|
4
4
|
|
5
5
|
# Manage which facts exist and how we access them. Largely just a wrapper
|
6
6
|
# around a hash of facts.
|
7
|
+
#
|
8
|
+
# @api private
|
7
9
|
class Facter::Util::Collection
|
8
10
|
|
9
11
|
def initialize(internal_loader, external_loader)
|
@@ -12,53 +14,40 @@ class Facter::Util::Collection
|
|
12
14
|
@external_loader = external_loader
|
13
15
|
end
|
14
16
|
|
15
|
-
# Return a fact object by name.
|
16
|
-
# 'value' on it to retrieve the actual value.
|
17
|
+
# Return a fact object by name.
|
17
18
|
def [](name)
|
18
19
|
value(name)
|
19
20
|
end
|
20
21
|
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@facts[name] = fact
|
30
|
-
end
|
31
|
-
|
32
|
-
# Set any fact-appropriate options.
|
33
|
-
options.each do |opt, value|
|
34
|
-
method = opt.to_s + "="
|
35
|
-
if fact.respond_to?(method)
|
36
|
-
fact.send(method, value)
|
37
|
-
options.delete(opt)
|
38
|
-
end
|
39
|
-
end
|
22
|
+
# Define a new fact or extend an existing fact.
|
23
|
+
#
|
24
|
+
# @param name [Symbol] The name of the fact to define
|
25
|
+
# @param options [Hash] A hash of options to set on the fact
|
26
|
+
#
|
27
|
+
# @return [Facter::Util::Fact] The fact that was defined
|
28
|
+
def define_fact(name, options = {}, &block)
|
29
|
+
fact = create_or_return_fact(name, options)
|
40
30
|
|
41
31
|
if block_given?
|
42
|
-
|
43
|
-
else
|
44
|
-
resolve = fact.add
|
32
|
+
fact.instance_eval(&block)
|
45
33
|
end
|
46
34
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
method = opt.to_s + "="
|
52
|
-
if resolve.respond_to?(method)
|
53
|
-
resolve.send(method, value)
|
54
|
-
options.delete(opt)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
35
|
+
fact
|
36
|
+
rescue => e
|
37
|
+
Facter.log_exception(e, "Unable to add fact #{name}: #{e}")
|
38
|
+
end
|
58
39
|
|
59
|
-
|
60
|
-
|
61
|
-
|
40
|
+
# Add a resolution mechanism for a named fact. This does not distinguish
|
41
|
+
# between adding a new fact and adding a new way to resolve a fact.
|
42
|
+
#
|
43
|
+
# @param name [Symbol] The name of the fact to define
|
44
|
+
# @param options [Hash] A hash of options to set on the fact and resolution
|
45
|
+
#
|
46
|
+
# @return [Facter::Util::Fact] The fact that was defined
|
47
|
+
def add(name, options = {}, &block)
|
48
|
+
fact = create_or_return_fact(name, options)
|
49
|
+
|
50
|
+
fact.add(options, &block)
|
62
51
|
|
63
52
|
return fact
|
64
53
|
end
|
@@ -144,6 +133,21 @@ class Facter::Util::Collection
|
|
144
133
|
|
145
134
|
private
|
146
135
|
|
136
|
+
def create_or_return_fact(name, options)
|
137
|
+
name = canonicalize(name)
|
138
|
+
|
139
|
+
fact = @facts[name]
|
140
|
+
|
141
|
+
if fact.nil?
|
142
|
+
fact = Facter::Util::Fact.new(name, options)
|
143
|
+
@facts[name] = fact
|
144
|
+
else
|
145
|
+
fact.extract_ldapname_option!(options)
|
146
|
+
end
|
147
|
+
|
148
|
+
fact
|
149
|
+
end
|
150
|
+
|
147
151
|
def canonicalize(name)
|
148
152
|
name.to_s.downcase.to_sym
|
149
153
|
end
|
data/lib/facter/util/config.rb
CHANGED
@@ -29,23 +29,33 @@ module Facter::Util::Config
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.external_facts_dirs=(dir)
|
33
|
+
@external_facts_dirs = dir
|
34
|
+
end
|
35
|
+
|
32
36
|
def self.external_facts_dirs
|
37
|
+
@external_facts_dirs
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.setup_default_ext_facts_dirs
|
33
41
|
if Facter::Util::Root.root?
|
34
42
|
windows_dir = windows_data_dir
|
35
43
|
if windows_dir.nil? then
|
36
|
-
["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
|
44
|
+
@external_facts_dirs = ["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
|
37
45
|
else
|
38
|
-
[File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
|
46
|
+
@external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
|
39
47
|
end
|
40
48
|
else
|
41
|
-
[File.expand_path(File.join("~", ".facter", "facts.d"))]
|
49
|
+
@external_facts_dirs = [File.expand_path(File.join("~", ".facter", "facts.d"))]
|
42
50
|
end
|
43
51
|
end
|
44
|
-
end
|
45
52
|
|
46
|
-
if Facter::Util::Config.is_windows?
|
47
|
-
|
48
|
-
|
49
|
-
else
|
50
|
-
|
53
|
+
if Facter::Util::Config.is_windows?
|
54
|
+
require 'win32/dir'
|
55
|
+
require 'facter/util/windows_root'
|
56
|
+
else
|
57
|
+
require 'facter/util/unix_root'
|
58
|
+
end
|
59
|
+
|
60
|
+
setup_default_ext_facts_dirs
|
51
61
|
end
|