facter 4.0.41 → 4.0.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docs/generate.rb +32 -0
  3. data/lib/docs/template.erb +34 -0
  4. data/lib/facter.rb +110 -25
  5. data/lib/facter/config.rb +386 -0
  6. data/lib/facter/custom_facts/core/aggregate.rb +51 -17
  7. data/lib/facter/custom_facts/core/execution.rb +54 -38
  8. data/lib/facter/custom_facts/core/execution/base.rb +46 -40
  9. data/lib/facter/custom_facts/util/collection.rb +1 -2
  10. data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
  11. data/lib/facter/custom_facts/util/fact.rb +19 -2
  12. data/lib/facter/custom_facts/util/loader.rb +1 -1
  13. data/lib/facter/custom_facts/util/parser.rb +17 -3
  14. data/lib/facter/custom_facts/util/resolution.rb +41 -12
  15. data/lib/facter/facts/aix/interfaces.rb +1 -0
  16. data/lib/facter/facts/aix/memory/swap/available.rb +1 -1
  17. data/lib/facter/facts/aix/memory/swap/available_bytes.rb +1 -1
  18. data/lib/facter/facts/aix/memory/swap/total.rb +1 -1
  19. data/lib/facter/facts/aix/memory/swap/total_bytes.rb +1 -1
  20. data/lib/facter/facts/aix/memory/swap/used.rb +1 -1
  21. data/lib/facter/facts/aix/memory/system/available.rb +1 -1
  22. data/lib/facter/facts/aix/memory/system/available_bytes.rb +1 -1
  23. data/lib/facter/facts/aix/memory/system/total.rb +1 -1
  24. data/lib/facter/facts/aix/memory/system/total_bytes.rb +1 -1
  25. data/lib/facter/facts/aix/memory/system/used.rb +1 -1
  26. data/lib/facter/facts/aix/processors/speed.rb +1 -1
  27. data/lib/facter/facts/bsd/processors/speed.rb +1 -1
  28. data/lib/facter/facts/freebsd/is_virtual.rb +25 -0
  29. data/lib/facter/facts/freebsd/memory/swap/available.rb +1 -1
  30. data/lib/facter/facts/freebsd/memory/swap/available_bytes.rb +1 -1
  31. data/lib/facter/facts/freebsd/memory/swap/total.rb +1 -1
  32. data/lib/facter/facts/freebsd/memory/swap/total_bytes.rb +1 -1
  33. data/lib/facter/facts/freebsd/memory/swap/used.rb +1 -1
  34. data/lib/facter/facts/freebsd/memory/system/available.rb +1 -1
  35. data/lib/facter/facts/freebsd/memory/system/available_bytes.rb +1 -1
  36. data/lib/facter/facts/freebsd/memory/system/total.rb +1 -1
  37. data/lib/facter/facts/freebsd/memory/system/total_bytes.rb +1 -1
  38. data/lib/facter/facts/freebsd/memory/system/used.rb +1 -1
  39. data/lib/facter/facts/freebsd/processors/speed.rb +1 -1
  40. data/lib/facter/facts/freebsd/virtual.rb +22 -0
  41. data/lib/facter/facts/linux/dhcp_servers.rb +1 -0
  42. data/lib/facter/facts/linux/ec2_metadata.rb +1 -1
  43. data/lib/facter/facts/linux/ec2_userdata.rb +1 -1
  44. data/lib/facter/facts/linux/hypervisors/kvm.rb +1 -1
  45. data/lib/facter/facts/linux/hypervisors/xen.rb +1 -1
  46. data/lib/facter/facts/linux/interfaces.rb +1 -0
  47. data/lib/facter/facts/linux/is_virtual.rb +2 -2
  48. data/lib/facter/facts/linux/memory/swap/available.rb +1 -1
  49. data/lib/facter/facts/linux/memory/swap/available_bytes.rb +1 -1
  50. data/lib/facter/facts/linux/memory/swap/total.rb +1 -1
  51. data/lib/facter/facts/linux/memory/swap/total_bytes.rb +1 -1
  52. data/lib/facter/facts/linux/memory/swap/used.rb +1 -1
  53. data/lib/facter/facts/linux/memory/system/available.rb +1 -1
  54. data/lib/facter/facts/linux/memory/system/available_bytes.rb +1 -1
  55. data/lib/facter/facts/linux/memory/system/total.rb +1 -1
  56. data/lib/facter/facts/linux/memory/system/total_bytes.rb +1 -1
  57. data/lib/facter/facts/linux/memory/system/used.rb +1 -1
  58. data/lib/facter/facts/linux/processors/speed.rb +1 -1
  59. data/lib/facter/facts/linux/virtual.rb +1 -1
  60. data/lib/facter/facts/macosx/dhcp_servers.rb +1 -0
  61. data/lib/facter/facts/macosx/interfaces.rb +1 -0
  62. data/lib/facter/facts/macosx/memory/swap/available.rb +1 -1
  63. data/lib/facter/facts/macosx/memory/swap/available_bytes.rb +1 -1
  64. data/lib/facter/facts/macosx/memory/swap/total.rb +1 -1
  65. data/lib/facter/facts/macosx/memory/swap/total_bytes.rb +1 -1
  66. data/lib/facter/facts/macosx/memory/swap/used.rb +1 -1
  67. data/lib/facter/facts/macosx/memory/system/available.rb +1 -1
  68. data/lib/facter/facts/macosx/memory/system/available_bytes.rb +1 -1
  69. data/lib/facter/facts/macosx/memory/system/total.rb +1 -1
  70. data/lib/facter/facts/macosx/memory/system/total_bytes.rb +1 -1
  71. data/lib/facter/facts/macosx/memory/system/used.rb +1 -1
  72. data/lib/facter/facts/macosx/processors/speed.rb +1 -1
  73. data/lib/facter/facts/rhel/os/release.rb +1 -1
  74. data/lib/facter/facts/solaris/dhcp_servers.rb +1 -0
  75. data/lib/facter/facts/solaris/hypervisors/ldom.rb +3 -0
  76. data/lib/facter/facts/solaris/interfaces.rb +1 -0
  77. data/lib/facter/facts/solaris/is_virtual.rb +2 -2
  78. data/lib/facter/facts/solaris/ldom.rb +34 -4
  79. data/lib/facter/facts/solaris/memory/swap/available.rb +1 -1
  80. data/lib/facter/facts/solaris/memory/swap/available_bytes.rb +1 -1
  81. data/lib/facter/facts/solaris/memory/swap/total.rb +1 -1
  82. data/lib/facter/facts/solaris/memory/swap/total_bytes.rb +1 -1
  83. data/lib/facter/facts/solaris/memory/swap/used.rb +1 -1
  84. data/lib/facter/facts/solaris/memory/system/available.rb +1 -1
  85. data/lib/facter/facts/solaris/memory/system/available_bytes.rb +1 -1
  86. data/lib/facter/facts/solaris/memory/system/total.rb +1 -1
  87. data/lib/facter/facts/solaris/memory/system/total_bytes.rb +1 -1
  88. data/lib/facter/facts/solaris/memory/system/used.rb +1 -1
  89. data/lib/facter/facts/solaris/processors/speed.rb +1 -1
  90. data/lib/facter/facts/solaris/virtual.rb +1 -1
  91. data/lib/facter/facts/solaris/zones.rb +1 -1
  92. data/lib/facter/facts/windows/dhcp_servers.rb +1 -0
  93. data/lib/facter/facts/windows/interfaces.rb +1 -0
  94. data/lib/facter/facts/windows/memory/system/available.rb +1 -1
  95. data/lib/facter/facts/windows/memory/system/available_bytes.rb +1 -1
  96. data/lib/facter/facts/windows/memory/system/total.rb +1 -1
  97. data/lib/facter/facts/windows/memory/system/total_bytes.rb +1 -1
  98. data/lib/facter/facts/windows/memory/system/used.rb +1 -1
  99. data/lib/facter/facts/windows/os/release.rb +1 -1
  100. data/lib/facter/framework/benchmarking/timer.rb +4 -2
  101. data/lib/facter/framework/cli/cli.rb +20 -6
  102. data/lib/facter/framework/config/fact_groups.rb +10 -8
  103. data/lib/facter/framework/core/cache_manager.rb +79 -29
  104. data/lib/facter/framework/core/fact/internal/core_fact.rb +6 -1
  105. data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +38 -4
  106. data/lib/facter/framework/core/fact_augmenter.rb +1 -1
  107. data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +4 -2
  108. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +17 -1
  109. data/lib/facter/framework/core/fact_manager.rb +15 -3
  110. data/lib/facter/framework/core/file_loader.rb +6 -2
  111. data/lib/facter/framework/core/options/config_file_options.rb +16 -5
  112. data/lib/facter/framework/core/options/option_store.rb +40 -20
  113. data/lib/facter/framework/detector/os_hierarchy.rb +5 -9
  114. data/lib/facter/framework/logging/logger.rb +3 -3
  115. data/lib/facter/models/fact_collection.rb +11 -1
  116. data/lib/facter/models/loaded_fact.rb +2 -1
  117. data/lib/facter/resolvers/aio_agent_version.rb +2 -2
  118. data/lib/facter/resolvers/aix/architecture_resolver.rb +19 -4
  119. data/lib/facter/resolvers/aix/disks.rb +6 -5
  120. data/lib/facter/resolvers/aix/filesystem_resolver.rb +2 -2
  121. data/lib/facter/resolvers/aix/hardware_resolver.rb +4 -3
  122. data/lib/facter/resolvers/aix/load_averages_resolver.rb +2 -1
  123. data/lib/facter/resolvers/aix/memory.rb +4 -3
  124. data/lib/facter/resolvers/aix/mountpoints.rb +6 -5
  125. data/lib/facter/resolvers/aix/networking_resolver.rb +4 -3
  126. data/lib/facter/resolvers/aix/nim.rb +1 -1
  127. data/lib/facter/resolvers/aix/os_level.rb +2 -2
  128. data/lib/facter/resolvers/aix/partitions.rb +7 -6
  129. data/lib/facter/resolvers/aix/processors.rb +5 -4
  130. data/lib/facter/resolvers/aix/serialnumber.rb +2 -2
  131. data/lib/facter/resolvers/augeas_resolver.rb +8 -2
  132. data/lib/facter/resolvers/base_resolver.rb +14 -4
  133. data/lib/facter/resolvers/bsd/processors.rb +13 -8
  134. data/lib/facter/resolvers/cloud.rb +2 -2
  135. data/lib/facter/resolvers/containers.rb +5 -4
  136. data/lib/facter/resolvers/debian_version.rb +2 -2
  137. data/lib/facter/resolvers/disk_resolver.rb +17 -6
  138. data/lib/facter/resolvers/dmi_decode.rb +1 -1
  139. data/lib/facter/resolvers/dmi_resolver.rb +5 -4
  140. data/lib/facter/resolvers/ec2.rb +5 -2
  141. data/lib/facter/resolvers/eos_release_resolver.rb +2 -2
  142. data/lib/facter/resolvers/facterversion_resolver.rb +1 -1
  143. data/lib/facter/resolvers/filesystems_resolver.rb +5 -2
  144. data/lib/facter/resolvers/fips_enabled_resolver.rb +5 -2
  145. data/lib/facter/resolvers/freebsd/dmi_resolver.rb +1 -1
  146. data/lib/facter/resolvers/freebsd/freebsd_version_resolver.rb +9 -7
  147. data/lib/facter/resolvers/freebsd/geom_resolver.rb +15 -22
  148. data/lib/facter/resolvers/freebsd/processors.rb +13 -8
  149. data/lib/facter/resolvers/freebsd/swap_memory_resolver.rb +5 -3
  150. data/lib/facter/resolvers/freebsd/system_memory_resolver.rb +4 -2
  151. data/lib/facter/resolvers/freebsd/virtual_resolver.rb +45 -0
  152. data/lib/facter/resolvers/gce.rb +3 -2
  153. data/lib/facter/resolvers/hostname_resolver.rb +69 -21
  154. data/lib/facter/resolvers/identity_resolver.rb +2 -1
  155. data/lib/facter/resolvers/linux/docker_uptime.rb +3 -2
  156. data/lib/facter/resolvers/linux/load_averages.rb +3 -2
  157. data/lib/facter/resolvers/load_averages.rb +5 -3
  158. data/lib/facter/resolvers/lpar_resolver.rb +1 -1
  159. data/lib/facter/resolvers/lsb_release_resolver.rb +1 -1
  160. data/lib/facter/resolvers/lspci.rb +1 -1
  161. data/lib/facter/resolvers/macosx/dmi_resolver.rb +1 -1
  162. data/lib/facter/resolvers/macosx/filesystems_resolver.rb +1 -1
  163. data/lib/facter/resolvers/macosx/load_averages_resolver.rb +2 -1
  164. data/lib/facter/resolvers/macosx/mountpoints_resolver.rb +9 -8
  165. data/lib/facter/resolvers/macosx/processor_resolver.rb +2 -1
  166. data/lib/facter/resolvers/macosx/swap_memory_resolver.rb +2 -1
  167. data/lib/facter/resolvers/macosx/system_memory_resolver.rb +2 -1
  168. data/lib/facter/resolvers/macosx/system_profiler_resolver.rb +4 -6
  169. data/lib/facter/resolvers/memory_resolver.rb +16 -16
  170. data/lib/facter/resolvers/mountpoints_resolver.rb +56 -25
  171. data/lib/facter/resolvers/networking_linux_resolver.rb +188 -83
  172. data/lib/facter/resolvers/networking_resolver.rb +9 -6
  173. data/lib/facter/resolvers/open_vz.rb +2 -4
  174. data/lib/facter/resolvers/os_release_resolver.rb +2 -2
  175. data/lib/facter/resolvers/partitions.rb +67 -63
  176. data/lib/facter/resolvers/path_resolver.rb +1 -1
  177. data/lib/facter/resolvers/processors_resolver.rb +10 -3
  178. data/lib/facter/resolvers/redhat_release_resolver.rb +2 -2
  179. data/lib/facter/resolvers/ruby_resolver.rb +1 -1
  180. data/lib/facter/resolvers/selinux_resolver.rb +4 -4
  181. data/lib/facter/resolvers/solaris/disks.rb +2 -2
  182. data/lib/facter/resolvers/solaris/dmi.rb +3 -1
  183. data/lib/facter/resolvers/solaris/dmi_sparc.rb +1 -1
  184. data/lib/facter/resolvers/solaris/filesystems.rb +1 -1
  185. data/lib/facter/resolvers/solaris/ipaddress.rb +2 -1
  186. data/lib/facter/resolvers/solaris/ldom.rb +1 -3
  187. data/lib/facter/resolvers/solaris/memory.rb +4 -3
  188. data/lib/facter/resolvers/solaris/mountpoints.rb +61 -0
  189. data/lib/facter/resolvers/solaris/networking.rb +51 -44
  190. data/lib/facter/resolvers/solaris/os_release.rb +7 -5
  191. data/lib/facter/resolvers/solaris/processors.rb +2 -1
  192. data/lib/facter/resolvers/solaris/zone.rb +1 -1
  193. data/lib/facter/resolvers/solaris/zone_name.rb +1 -1
  194. data/lib/facter/resolvers/ssh_resolver.rb +11 -7
  195. data/lib/facter/resolvers/suse_release_resolver.rb +2 -2
  196. data/lib/facter/resolvers/sw_vers_resolver.rb +2 -2
  197. data/lib/facter/resolvers/timezone_resolver.rb +1 -1
  198. data/lib/facter/resolvers/uname_resolver.rb +1 -1
  199. data/lib/facter/resolvers/uptime_resolver.rb +3 -3
  200. data/lib/facter/resolvers/virt_what.rb +1 -1
  201. data/lib/facter/resolvers/vmware.rb +1 -1
  202. data/lib/facter/resolvers/windows/aio_agent_version.rb +2 -2
  203. data/lib/facter/resolvers/windows/dmi_bios_resolver.rb +2 -2
  204. data/lib/facter/resolvers/windows/dmi_computersystem_resolver.rb +2 -2
  205. data/lib/facter/resolvers/windows/fips_resolver.rb +2 -1
  206. data/lib/facter/resolvers/windows/hardware_architecture_resolver.rb +2 -1
  207. data/lib/facter/resolvers/windows/identity_resolver.rb +2 -1
  208. data/lib/facter/resolvers/windows/kernel_resolver.rb +3 -1
  209. data/lib/facter/resolvers/windows/memory_resolver.rb +7 -1
  210. data/lib/facter/resolvers/windows/netkvm_resolver.rb +2 -1
  211. data/lib/facter/resolvers/windows/networking_resolver.rb +5 -4
  212. data/lib/facter/resolvers/windows/processors_resolver.rb +3 -2
  213. data/lib/facter/resolvers/windows/product_release_resolver.rb +2 -1
  214. data/lib/facter/resolvers/windows/ssh.rb +5 -3
  215. data/lib/facter/resolvers/windows/system32_resolver.rb +3 -1
  216. data/lib/facter/resolvers/windows/uptime_resolver.rb +3 -2
  217. data/lib/facter/resolvers/windows/virtualization_resolver.rb +3 -2
  218. data/lib/facter/resolvers/windows/win_os_description_resolver.rb +4 -2
  219. data/lib/facter/resolvers/wpar_resolver.rb +1 -1
  220. data/lib/facter/resolvers/xen.rb +2 -2
  221. data/lib/facter/resolvers/zfs.rb +2 -1
  222. data/lib/facter/resolvers/zpool.rb +2 -1
  223. data/lib/facter/util/aix/info_extractor.rb +24 -0
  224. data/lib/facter/util/aix/odm_query.rb +46 -0
  225. data/lib/facter/util/api_debugger.rb +33 -29
  226. data/lib/facter/util/facts/facts_utils.rb +14 -0
  227. data/lib/facter/util/facts/unit_converter.rb +61 -0
  228. data/lib/facter/util/facts/uptime_parser.rb +128 -0
  229. data/lib/facter/util/facts/virtual_detector.rb +90 -0
  230. data/lib/facter/util/facts/windows_release_finder.rb +55 -0
  231. data/lib/facter/{resolvers/macosx/utils → util/macosx}/system_profile_executor.rb +1 -1
  232. data/lib/facter/util/resolvers/aws_token.rb +37 -0
  233. data/lib/facter/{resolvers/utils → util/resolvers}/ffi/load_averages.rb +2 -2
  234. data/lib/facter/util/resolvers/filesystem_helper.rb +47 -0
  235. data/lib/facter/util/resolvers/fingerprint.rb +15 -0
  236. data/lib/facter/{resolvers/utils → util/resolvers}/http.rb +17 -10
  237. data/lib/facter/util/resolvers/networking.rb +90 -0
  238. data/lib/facter/util/resolvers/networking/dhcp.rb +21 -0
  239. data/lib/facter/util/resolvers/networking/networking.rb +109 -0
  240. data/lib/facter/util/resolvers/networking/primary_interface.rb +82 -0
  241. data/lib/facter/util/resolvers/ssh.rb +17 -0
  242. data/lib/facter/util/resolvers/ssh_helper.rb +31 -0
  243. data/lib/facter/{resolvers/utils → util/resolvers}/uptime_helper.rb +2 -2
  244. data/lib/facter/{framework/utils → util}/utils.rb +0 -0
  245. data/lib/facter/util/windows/win32ole.rb +30 -0
  246. data/lib/facter/version.rb +1 -1
  247. metadata +33 -44
  248. data/lib/facter/fact_groups.conf +0 -308
  249. data/lib/facter/facts/aix/puppet_version.rb +0 -15
  250. data/lib/facter/facts/freebsd/puppet_version.rb +0 -15
  251. data/lib/facter/facts/linux/puppet_version.rb +0 -15
  252. data/lib/facter/facts/macosx/puppet_version.rb +0 -15
  253. data/lib/facter/facts/solaris/puppet_version.rb +0 -15
  254. data/lib/facter/facts/windows/puppet_version.rb +0 -15
  255. data/lib/facter/facts_utils/facts_utils.rb +0 -12
  256. data/lib/facter/facts_utils/unit_converter.rb +0 -59
  257. data/lib/facter/facts_utils/uptime_parser.rb +0 -124
  258. data/lib/facter/facts_utils/virtual_detector.rb +0 -78
  259. data/lib/facter/facts_utils/windows_release_finder.rb +0 -51
  260. data/lib/facter/os_hierarchy.json +0 -36
  261. data/lib/facter/resolvers/aix/utils/info_extractor.rb +0 -20
  262. data/lib/facter/resolvers/aix/utils/odm_query.rb +0 -42
  263. data/lib/facter/resolvers/puppet_version_resolver.rb +0 -26
  264. data/lib/facter/resolvers/utils/filesystem_helper.rb +0 -43
  265. data/lib/facter/resolvers/utils/fingerprint.rb +0 -11
  266. data/lib/facter/resolvers/utils/networking.rb +0 -86
  267. data/lib/facter/resolvers/utils/ssh.rb +0 -13
  268. data/lib/facter/resolvers/utils/ssh_helper.rb +0 -27
  269. data/lib/facter/resolvers/windows/utils/win32ole.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c21fc41638fbbab14ccb415eec2104ed296236c98d7870a341c37742796c8fc1
4
- data.tar.gz: 7b09bdc7ecc99e1947d9eb5bcacb7873f3b954224904d0930ee69846c47d5e88
3
+ metadata.gz: 87e1b483df51f967d4e88c90f67ddfef304184d235d08746500c61619c56dee2
4
+ data.tar.gz: d573d4d221bc71e512c36a2f8218b0d70512ace56cb0eaa37dba3a9eee27bcde
5
5
  SHA512:
6
- metadata.gz: 327664693c0725ab4aafc339e6091557dc00d2dee945a9f6d6f3bca5d3a6d1ab8b56809c5d9b7374029fcd277a8bc5107ff76a03522c9104e214f4c967417a04
7
- data.tar.gz: 2d60b83c461d1bcdaa611322061f844f186951341562b5a3ec83d35512d58059776a5772b41bdf97b2cb77c2fb53abd2a744f9bddc49042b6d421868411c010a
6
+ metadata.gz: 49f5a8c11e45cdc6e9550e6fa50335700b8c43c048b46b1f091ea4b4a1f66588865a36c2ca1b447bea72c80a1548ca37d6f998eca4187047c6f2e95b2daf87d5
7
+ data.tar.gz: b6b21071a59dbfedc1499b6464e2556aa272f9fc99feb1674c6961a1a3a564570e9a7df127ad80140703ee320f73b1e41c82deec41dfb4160814544f1a0ae2d4
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Generates a markdown file containing fact documentation.
5
+ # usage: ruby generate.rb > facts.md
6
+
7
+ require 'yaml'
8
+ require 'erb'
9
+ require 'ostruct'
10
+
11
+ PATH_TO_SCHEMA = File.join(File.dirname(__FILE__), '../schema/facter.yaml')
12
+ PATH_TO_TEMPLATE = File.join(File.dirname(__FILE__), 'template.erb')
13
+
14
+ schema = YAML.load_file(PATH_TO_SCHEMA)
15
+
16
+ def format_facts(fact_hash)
17
+ scope = OpenStruct.new({
18
+ facts: fact_hash
19
+ })
20
+
21
+ erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
22
+ ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
23
+ else
24
+ ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-')
25
+ end
26
+ erb.result(scope.instance_eval { binding })
27
+ end
28
+
29
+ print "## Modern Facts\n\n"
30
+ print format_facts(schema.reject { |_name, info| info['hidden'] == true })
31
+ print "## Legacy Facts\n\n"
32
+ print format_facts(schema.reject { |_name, info| info['hidden'].nil? || info['hidden'] == false })
@@ -0,0 +1,34 @@
1
+ <%# This template is used to generate a markdown file documenting facts. -%>
2
+ <%# Run 'ruby generate.rb > facts.md' to generate the markdown file. -%>
3
+ <%
4
+ def format_fact_element(name, info, indent = '')
5
+ subelements = (info['elements'] || {}).map{|n, i| format_fact_element(n, i, "#{indent} ")}.join('')
6
+
7
+ "#{indent}* `#{name}` (#{info['type']}) --- #{info['description']}\n#{subelements}"
8
+ end
9
+ -%>
10
+ <% facts.each do |name, schema| -%>
11
+ ### `<%= name %>`
12
+
13
+ <% if schema['hidden'] -%>
14
+ This legacy fact is hidden by default in Facter's command-line output.
15
+
16
+ <% end -%>
17
+ **Type:** <%= schema['type'] %>
18
+
19
+ **Purpose:**
20
+
21
+ <%= schema['description'] %>
22
+
23
+ <% if schema['elements'] -%>
24
+ **Elements:**
25
+
26
+ <%= schema['elements'].map{|name, info| format_fact_element(name, info)}.join('') %>
27
+ <% end -%>
28
+
29
+ <% if schema['details'] -%>
30
+ **Details:**
31
+
32
+ <%= schema['details'] %>
33
+ <% end -%>
34
+ <% end -%>
@@ -17,6 +17,12 @@ module Facter
17
17
  @warn_once = []
18
18
 
19
19
  class << self
20
+ # Method used by puppet-agent to retrieve facts
21
+ # @param args_as_string [string] facter cli arguments
22
+ #
23
+ # @return query result
24
+ #
25
+ # @api private
20
26
  def resolve(args_as_string)
21
27
  require 'facter/framework/cli/cli_launcher'
22
28
 
@@ -38,10 +44,6 @@ module Facter
38
44
  end
39
45
  end
40
46
 
41
- def clear_messages
42
- logger.debug('clear_messages is not implemented')
43
- end
44
-
45
47
  # Alias method for Facter.fact()
46
48
  # @param name [string] fact name
47
49
  #
@@ -83,8 +85,16 @@ module Facter
83
85
  Options[:custom_dir] = []
84
86
  LegacyFacter.collection.invalidate_custom_facts
85
87
  LegacyFacter.collection.reload_custom_facts
88
+ SessionCache.invalidate_all_caches
89
+ nil
86
90
  end
87
91
 
92
+ # Gets the value for a core fact, external or custom facts are
93
+ # not returned with this call. Returns `nil` if no such fact exists.
94
+ #
95
+ # @return [FactCollection] hash with fact names and values
96
+ #
97
+ # @api private
88
98
  def core_value(user_query)
89
99
  user_query = user_query.to_s
90
100
  resolved_facts = Facter::FactManager.instance.resolve_core([user_query])
@@ -136,8 +146,16 @@ module Facter
136
146
  LegacyFacter.define_fact(name, options, &block)
137
147
  end
138
148
 
149
+ # Stores a proc that will be used to output custom messages.
150
+ # The proc must receive one parameter that will be the message to log.
151
+ # @param block [Proc] a block defining messages handler
152
+ #
153
+ # @return [nil]
154
+ #
155
+ # @api public
139
156
  def on_message(&block)
140
157
  Facter::Log.on_message(&block)
158
+ nil
141
159
  end
142
160
 
143
161
  # Check whether debugging is enabled
@@ -159,6 +177,18 @@ module Facter
159
177
  Facter::Options[:debug] = debug_bool
160
178
  end
161
179
 
180
+ def enable_sequential
181
+ Facter::Options[:sequential] = true
182
+ end
183
+
184
+ def disable_sequential
185
+ Facter::Options[:sequential] = false
186
+ end
187
+
188
+ def sequential?
189
+ Facter::Options[:sequential]
190
+ end
191
+
162
192
  # Iterates over fact names and values
163
193
  #
164
194
  # @yieldparam [String] name the fact name
@@ -170,7 +200,6 @@ module Facter
170
200
  def each
171
201
  log_blocked_facts
172
202
  resolved_facts = Facter::FactManager.instance.resolve_facts
173
- SessionCache.invalidate_all_caches
174
203
 
175
204
  resolved_facts.each do |fact|
176
205
  yield(fact.name, fact.value)
@@ -206,6 +235,19 @@ module Facter
206
235
  LegacyFacter.reset
207
236
  Options[:custom_dir] = []
208
237
  Options[:external_dir] = []
238
+ SessionCache.invalidate_all_caches
239
+ nil
240
+ end
241
+
242
+ # Flushes cached values for all facts. This does not cause code to be
243
+ # reloaded; it only clears the cached results.
244
+ #
245
+ # @return [void]
246
+ #
247
+ # @api public
248
+ def flush
249
+ LegacyFacter.flush
250
+ SessionCache.invalidate_all_caches
209
251
  nil
210
252
  end
211
253
 
@@ -219,27 +261,47 @@ module Facter
219
261
  nil
220
262
  end
221
263
 
222
- # Register directories to be searched for custom facts. The registered directories
223
- # must be absolute paths or they will be ignored.
264
+ # Enables/Disables external facts.
265
+ # @param enable_external [boolean]
224
266
  #
267
+ # @return nil
268
+ #
269
+ # @api public
270
+ def load_external(enable_external)
271
+ # enable_external param needs negation because behind the scene
272
+ # no_external_facts= method is negating the parameter again.
273
+ Options[:no_external_facts] = !enable_external
274
+
275
+ if enable_external
276
+ logger.debug('Facter.load_external(true) called. External facts will be loaded')
277
+ else
278
+ logger.debug('Facter.load_external(false) called. External facts will NOT be loaded')
279
+ end
280
+
281
+ nil
282
+ end
283
+
284
+ # Register directories to be searched for custom facts. The registered directories
285
+ # must be absolute paths or they will be ignored.
225
286
  # @param dirs [Array<String>] An array of searched directories
226
287
  #
227
- # @return [void]
288
+ # @return [nil]
228
289
  #
229
290
  # @api public
230
291
  def search(*dirs)
231
292
  Options[:custom_dir] += dirs
293
+ nil
232
294
  end
233
295
 
234
296
  # Registers directories to be searched for external facts.
235
- #
236
297
  # @param dirs [Array<String>] An array of searched directories
237
298
  #
238
- # @return [void]
299
+ # @return [nil]
239
300
  #
240
301
  # @api public
241
302
  def search_external(dirs)
242
303
  Options[:external_dir] += dirs
304
+ nil
243
305
  end
244
306
 
245
307
  # Returns the registered search directories.for external facts.
@@ -263,15 +325,17 @@ module Facter
263
325
  # Gets a hash mapping fact names to their values
264
326
  # The hash contains core facts, legacy facts, custom facts and external facts (all facts that can be resolved).
265
327
  #
266
- # @return [FactCollection] the hash of fact names and values
328
+ # @return [FactCollection] hash with fact names and values
267
329
  #
268
330
  # @api public
269
331
  def to_hash
270
332
  log_blocked_facts
333
+ logger.debug("Facter version: #{Facter::VERSION}")
271
334
 
272
335
  resolved_facts = Facter::FactManager.instance.resolve_facts
273
- Facter::SessionCache.invalidate_all_caches
274
- Facter::FactCollection.new.build_fact_collection!(resolved_facts)
336
+ resolved_facts.reject! { |fact| fact.type == :custom && fact.value.nil? }
337
+ collection = Facter::FactCollection.new.build_fact_collection!(resolved_facts)
338
+ Hash[collection]
275
339
  end
276
340
 
277
341
  # Check whether printing stack trace is enabled
@@ -286,7 +350,7 @@ module Facter
286
350
  # Enable or disable trace
287
351
  # @param bool [bool] Set trace on debug state
288
352
  #
289
- # @return [type] [description]
353
+ # @return [bool] Value of trace debug state
290
354
  #
291
355
  # @api public
292
356
  def trace(bool)
@@ -305,10 +369,22 @@ module Facter
305
369
  @already_searched[user_query]&.value
306
370
  end
307
371
 
372
+ # Gets the values for multiple facts.
373
+ #
374
+ # @param options [Hash] parameters for the fact - attributes
375
+ # of {Facter::Util::Fact} and {Facter::Util::Resolution} can be
376
+ # supplied here
377
+ # @param user_queries [Array] the fact names
378
+ #
379
+ # @return [FactCollection] hash with fact names and values
380
+ #
381
+ # @api public
308
382
  def values(options, user_queries)
309
383
  init_cli_options(options, user_queries)
384
+ Options[:show_legacy] = true
385
+ log_blocked_facts
310
386
  resolved_facts = Facter::FactManager.instance.resolve_facts(user_queries)
311
- Facter::SessionCache.invalidate_all_caches
387
+ resolved_facts.reject! { |fact| fact.type == :custom && fact.value.nil? }
312
388
 
313
389
  if user_queries.count.zero?
314
390
  Facter::FactCollection.new.build_fact_collection!(resolved_facts)
@@ -334,16 +410,20 @@ module Facter
334
410
  def to_user_output(cli_options, *args)
335
411
  init_cli_options(cli_options, args)
336
412
  logger.info("executed with command line: #{ARGV.drop(1).join(' ')}")
413
+ logger.debug("Facter version: #{Facter::VERSION}")
337
414
  log_blocked_facts
338
- resolved_facts = Facter::FactManager.instance.resolve_facts(args)
339
- SessionCache.invalidate_all_caches
415
+ resolved_facts = resolve_facts_for_user_query(args)
340
416
  fact_formatter = Facter::FormatterFactory.build(Facter::Options.get)
341
-
342
417
  status = error_check(resolved_facts)
343
418
 
344
- [fact_formatter.format(resolved_facts), status || 0]
419
+ [fact_formatter.format(resolved_facts), status]
345
420
  end
346
421
 
422
+ # Logs an exception and an optional message
423
+ #
424
+ # @return [nil]
425
+ #
426
+ # @api public
347
427
  def log_exception(exception, message = nil)
348
428
  error_message = []
349
429
 
@@ -351,10 +431,10 @@ module Facter
351
431
 
352
432
  parse_exception(exception, error_message)
353
433
  logger.error(error_message.flatten.join("\n"))
434
+ nil
354
435
  end
355
436
 
356
437
  # Returns a list with the names of all solved facts
357
- #
358
438
  # @return [Array] the list with all the fact names
359
439
  #
360
440
  # @api public
@@ -363,7 +443,6 @@ module Facter
363
443
  end
364
444
 
365
445
  # Logs the message parameter as a warning.
366
- #
367
446
  # @param message [Object] the warning object to be displayed
368
447
  #
369
448
  # @return [nil]
@@ -375,7 +454,6 @@ module Facter
375
454
  end
376
455
 
377
456
  # Logs only once the same warning message.
378
- #
379
457
  # @param message [Object] the warning message object
380
458
  #
381
459
  # @return [nil]
@@ -392,6 +470,15 @@ module Facter
392
470
 
393
471
  private
394
472
 
473
+ def resolve_facts_for_user_query(user_query)
474
+ resolved_facts = Facter::FactManager.instance.resolve_facts(user_query)
475
+ user_querie = resolved_facts.uniq(&:user_query).map(&:user_query).first
476
+
477
+ resolved_facts.reject! { |fact| fact.type == :custom && fact.value.nil? } if user_querie&.empty?
478
+
479
+ resolved_facts
480
+ end
481
+
395
482
  def parse_exception(exception, error_message)
396
483
  if exception.is_a?(Exception)
397
484
  error_message << exception.message if error_message.empty?
@@ -426,7 +513,6 @@ module Facter
426
513
  def resolve_fact(user_query)
427
514
  user_query = user_query.to_s
428
515
  resolved_facts = Facter::FactManager.instance.resolve_facts([user_query])
429
- SessionCache.invalidate_all_caches
430
516
  # we must make a distinction between custom facts that return nil and nil facts
431
517
  # Nil facts should not be packaged as ResolvedFacts! (add_fact_to_searched_facts packages facts)
432
518
  resolved_facts = resolved_facts.reject { |fact| fact.type == :nil }
@@ -451,14 +537,13 @@ module Facter
451
537
  #
452
538
  # @api private
453
539
  def error_check(resolved_facts)
540
+ status = 0
454
541
  if Options[:strict]
455
542
  missing_names = resolved_facts.select { |fact| fact.type == :nil }.map(&:user_query)
456
543
 
457
544
  if missing_names.count.positive?
458
545
  status = 1
459
546
  log_errors(missing_names)
460
- else
461
- status = nil
462
547
  end
463
548
  end
464
549
 
@@ -0,0 +1,386 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Config
5
+ unless defined?(OS_HIERARCHY)
6
+ OS_HIERARCHY = [
7
+ {
8
+ 'Linux' => [
9
+ {
10
+ 'Debian' => %w[
11
+ Elementary
12
+ Ubuntu
13
+ Raspbian
14
+ ]
15
+ },
16
+ {
17
+ 'Rhel' => %w[
18
+ Fedora
19
+ Amzn
20
+ Centos
21
+ Ol
22
+ Scientific
23
+ ]
24
+ },
25
+ {
26
+ 'Sles' => [
27
+ 'Opensuse'
28
+ ]
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ 'Bsd' => [
34
+ 'Freebsd'
35
+ ]
36
+ },
37
+ 'Solaris',
38
+ 'Macosx',
39
+ 'Windows',
40
+ 'Aix'
41
+ ].freeze
42
+ end
43
+ unless defined? FACT_GROUPS
44
+ FACT_GROUPS = {
45
+ 'AIX NIM type' => [
46
+ 'nim_type'
47
+ ],
48
+ 'EC2' => %w[
49
+ ec2_metadata
50
+ ec2_userdata
51
+ ],
52
+ 'GCE' => [
53
+ 'gce'
54
+ ],
55
+ 'Xen' => %w[
56
+ xen
57
+ xendomains
58
+ ],
59
+ 'augeas' => %w[
60
+ augeas
61
+ augeasversion
62
+ ],
63
+ 'desktop management interface' => %w[
64
+ dmi
65
+ bios_vendor
66
+ bios_version
67
+ bios_release_date
68
+ boardassettag
69
+ boardmanufacturer
70
+ boardproductname
71
+ boardserialnumber
72
+ chassisassettag
73
+ manufacturer
74
+ productname
75
+ serialnumber
76
+ uuid
77
+ chassistype
78
+ ],
79
+ 'disks' => %w[
80
+ blockdevices
81
+ disks
82
+ ],
83
+ 'file system' => %w[
84
+ mountpoints
85
+ filesystems
86
+ partitions
87
+ ],
88
+ 'fips' => [
89
+ 'fips_enabled'
90
+ ],
91
+ 'hypervisors' => [
92
+ 'hypervisors'
93
+ ],
94
+ 'id' => %w[
95
+ id
96
+ gid
97
+ identity
98
+ ],
99
+ 'kernel' => %w[
100
+ kernel
101
+ kernelversion
102
+ kernelrelease
103
+ kernelmajversion
104
+ ],
105
+ 'load_average' => [
106
+ 'load_averages'
107
+ ],
108
+ 'memory' => %w[
109
+ memory
110
+ memoryfree
111
+ memoryfree_mb
112
+ memorysize
113
+ memorysize_mb
114
+ swapfree
115
+ swapfree_mb
116
+ swapsize
117
+ swapsize_mb
118
+ swapencrypted
119
+ ],
120
+ 'networking' => %w[
121
+ networking
122
+ hostname
123
+ ipaddress
124
+ ipaddress6
125
+ netmask
126
+ netmask6
127
+ network
128
+ network6
129
+ scope6
130
+ macaddress
131
+ interfaces
132
+ domain
133
+ fqdn
134
+ dhcp_servers
135
+ ],
136
+ 'operating system' => %w[
137
+ os
138
+ operatingsystem
139
+ osfamily
140
+ operatingsystemrelease
141
+ operatingsystemmajrelease
142
+ hardwaremodel
143
+ architecture
144
+ lsbdistid
145
+ lsbdistrelease
146
+ lsbdistcodename
147
+ lsbdistdescription
148
+ lsbmajdistrelease
149
+ lsbminordistrelease
150
+ lsbrelease
151
+ macosx_buildversion
152
+ macosx_productname
153
+ macosx_productversion
154
+ macosx_productversion_major
155
+ macosx_productversion_minor
156
+ windows_edition_id
157
+ windows_installation_type
158
+ windows_product_name
159
+ windows_release_id
160
+ system32
161
+ selinux
162
+ selinux_enforced
163
+ selinux_policyversion
164
+ selinux_current_mode
165
+ selinux_config_mode
166
+ selinux_config_policy
167
+ ],
168
+ 'path' => [
169
+ 'path'
170
+ ],
171
+ 'processor' => %w[
172
+ processors
173
+ processorcount
174
+ physicalprocessorcount
175
+ hardwareisa
176
+ ],
177
+ 'ssh' => %w[
178
+ ssh
179
+ sshdsakey
180
+ sshrsakey
181
+ sshecdsakey
182
+ sshed25519key
183
+ sshfp_dsa
184
+ sshfp_rsa
185
+ sshfp_ecdsa
186
+ sshfp_ed25519
187
+ ],
188
+ 'system profiler' => %w[
189
+ system_profiler
190
+ sp_boot_mode
191
+ sp_boot_rom_version
192
+ sp_boot_volume
193
+ sp_cpu_type
194
+ sp_current_processor_speed
195
+ sp_kernel_version
196
+ sp_l2_cache_core
197
+ sp_l3_cache
198
+ sp_local_host_name
199
+ sp_machine_model
200
+ sp_machine_name
201
+ sp_number_processors
202
+ sp_os_version
203
+ sp_packages
204
+ sp_physical_memory
205
+ sp_platform_uuid
206
+ sp_secure_vm
207
+ sp_serial_number
208
+ sp_smc_version_system
209
+ sp_uptime
210
+ sp_user_name
211
+ ],
212
+ 'timezone' => [
213
+ 'timezone'
214
+ ],
215
+ 'uptime' => %w[
216
+ system_uptime
217
+ uptime
218
+ uptime_days
219
+ uptime_hours
220
+ uptime_seconds
221
+ ],
222
+ 'virtualization' => %w[
223
+ virtual
224
+ is_virtual
225
+ cloud
226
+ ],
227
+ 'ldom' => [
228
+ 'ldom'
229
+ ],
230
+ 'Solaris zone' => %w[
231
+ zones
232
+ zonename
233
+ solaris_zones
234
+ ],
235
+ 'ZFS' => %w[
236
+ zfs_version
237
+ zfs_featurenumbers
238
+ ],
239
+ 'ZFS storage pool' => %w[
240
+ zpool_version
241
+ zpool_featureflags
242
+ zpool_featurenumbers
243
+ ],
244
+ 'legacy' => [
245
+ 'architecture',
246
+ 'augeasversion',
247
+ 'bios_release_date',
248
+ 'bios_vendor',
249
+ 'bios_version',
250
+ 'blockdevice_*_model',
251
+ 'blockdevice_*_size',
252
+ 'blockdevice_*_vendor',
253
+ 'blockdevices',
254
+ 'boardassettag',
255
+ 'boardmanufacturer',
256
+ 'boardproductname',
257
+ 'boardserialnumber',
258
+ 'chassisassettag',
259
+ 'chassistype',
260
+ 'dhcp_servers',
261
+ 'domain',
262
+ 'fqdn',
263
+ 'gid',
264
+ 'hardwareisa',
265
+ 'hardwaremodel',
266
+ 'hostname',
267
+ 'id',
268
+ 'interfaces',
269
+ 'ipaddress',
270
+ 'ipaddress_.*',
271
+ 'ipaddress_*',
272
+ 'ipaddress6',
273
+ 'ipaddress6_.*',
274
+ 'ipaddress6_*',
275
+ 'ldom_*',
276
+ 'lsbdistcodename',
277
+ 'lsbdistdescription',
278
+ 'lsbdistid',
279
+ 'lsbdistrelease',
280
+ 'lsbmajdistrelease',
281
+ 'lsbminordistrelease',
282
+ 'lsbrelease',
283
+ 'macaddress',
284
+ 'macaddress_.*',
285
+ 'macaddress_*',
286
+ 'macosx_buildversion',
287
+ 'macosx_productname',
288
+ 'macosx_productversion',
289
+ 'macosx_productversion_major',
290
+ 'macosx_productversion_minor',
291
+ 'manufacturer',
292
+ 'memoryfree',
293
+ 'memoryfree_mb',
294
+ 'memorysize',
295
+ 'memorysize_mb',
296
+ 'mtu_.*',
297
+ 'mtu_*',
298
+ 'netmask',
299
+ 'netmask_.*',
300
+ 'netmask_*',
301
+ 'netmask6',
302
+ 'netmask6_.*',
303
+ 'netmask6_*',
304
+ 'network',
305
+ 'network_.*',
306
+ 'network_*',
307
+ 'network6',
308
+ 'network6_.*',
309
+ 'network6_*',
310
+ 'operatingsystem',
311
+ 'operatingsystemmajrelease',
312
+ 'operatingsystemrelease',
313
+ 'osfamily',
314
+ 'physicalprocessorcount',
315
+ 'processor.*',
316
+ 'processor*',
317
+ 'processorcount',
318
+ 'productname',
319
+ 'rubyplatform',
320
+ 'rubysitedir',
321
+ 'rubyversion',
322
+ 'scope6',
323
+ 'scope6_.*',
324
+ 'selinux',
325
+ 'selinux_config_mode',
326
+ 'selinux_config_policy',
327
+ 'selinux_current_mode',
328
+ 'selinux_enforced',
329
+ 'selinux_policyversion',
330
+ 'serialnumber',
331
+ 'sp_*',
332
+ 'sp_boot_mode',
333
+ 'sp_boot_rom_version',
334
+ 'sp_boot_volume',
335
+ 'sp_cpu_type',
336
+ 'sp_current_processor_speed',
337
+ 'sp_kernel_version',
338
+ 'sp_l2_cache_core',
339
+ 'sp_l3_cache',
340
+ 'sp_local_host_name',
341
+ 'sp_machine_model',
342
+ 'sp_machine_name',
343
+ 'sp_number_processors',
344
+ 'sp_os_version',
345
+ 'sp_packages',
346
+ 'sp_physical_memory',
347
+ 'sp_platform_uuid',
348
+ 'sp_secure_vm',
349
+ 'sp_serial_number',
350
+ 'sp_smc_version_system',
351
+ 'sp_uptime',
352
+ 'sp_user_name',
353
+ 'ssh.*key',
354
+ 'ssh*key',
355
+ 'sshfp_.*',
356
+ 'sshfp_*',
357
+ 'swapencrypted',
358
+ 'swapfree',
359
+ 'swapfree_mb',
360
+ 'swapsize',
361
+ 'swapsize_mb',
362
+ 'system32',
363
+ 'uptime',
364
+ 'uptime_days',
365
+ 'uptime_hours',
366
+ 'uptime_seconds',
367
+ 'uuid',
368
+ 'windows_edition_id',
369
+ 'windows_installation_type',
370
+ 'windows_product_name',
371
+ 'windows_release_id',
372
+ 'xendomains',
373
+ 'zone_*_brand',
374
+ 'zone_*_id',
375
+ 'zone_*_iptype',
376
+ 'zone_*_name',
377
+ 'zone_*_path',
378
+ 'zone_*_status',
379
+ 'zone_*_uuid',
380
+ 'zonename',
381
+ 'zones'
382
+ ]
383
+ }.freeze
384
+ end
385
+ end
386
+ end