facter 4.6.1 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docs/generate.rb +6 -1
  3. data/lib/facter/config.rb +3 -2
  4. data/lib/facter/custom_facts/core/aggregate.rb +5 -1
  5. data/lib/facter/custom_facts/util/confine.rb +4 -2
  6. data/lib/facter/facts/linux/cloud/provider.rb +6 -3
  7. data/lib/facter/facts/openbsd/augeas/version.rb +19 -0
  8. data/lib/facter/facts/openbsd/dmi/bios/vendor.rb +19 -0
  9. data/lib/facter/facts/openbsd/dmi/bios/version.rb +19 -0
  10. data/lib/facter/facts/openbsd/dmi/manufacturer.rb +17 -0
  11. data/lib/facter/facts/openbsd/dmi/product/name.rb +19 -0
  12. data/lib/facter/facts/openbsd/dmi/product/serial_number.rb +19 -0
  13. data/lib/facter/facts/openbsd/dmi/product/uuid.rb +19 -0
  14. data/lib/facter/facts/openbsd/ec2_metadata.rb +23 -0
  15. data/lib/facter/facts/openbsd/ec2_userdata.rb +23 -0
  16. data/lib/facter/facts/openbsd/facterversion.rb +14 -0
  17. data/lib/facter/facts/openbsd/identity/gid.rb +16 -0
  18. data/lib/facter/facts/openbsd/identity/group.rb +18 -0
  19. data/lib/facter/facts/openbsd/identity/privileged.rb +16 -0
  20. data/lib/facter/facts/openbsd/identity/uid.rb +16 -0
  21. data/lib/facter/facts/openbsd/identity/user.rb +17 -0
  22. data/lib/facter/facts/openbsd/ipaddress6_interfaces.rb +20 -0
  23. data/lib/facter/facts/openbsd/ipaddress_interfaces.rb +20 -0
  24. data/lib/facter/facts/openbsd/is_virtual.rb +21 -0
  25. data/lib/facter/facts/openbsd/kernel.rb +14 -0
  26. data/lib/facter/facts/openbsd/kernelrelease.rb +14 -0
  27. data/lib/facter/facts/openbsd/mountpoints.rb +21 -0
  28. data/lib/facter/facts/openbsd/netmask6_interfaces.rb +20 -0
  29. data/lib/facter/facts/openbsd/netmask_interfaces.rb +20 -0
  30. data/lib/facter/facts/openbsd/network6_interfaces.rb +20 -0
  31. data/lib/facter/facts/openbsd/network_interfaces.rb +20 -0
  32. data/lib/facter/facts/openbsd/networking/dhcp.rb +17 -0
  33. data/lib/facter/facts/openbsd/networking/domain.rb +18 -0
  34. data/lib/facter/facts/openbsd/networking/fqdn.rb +18 -0
  35. data/lib/facter/facts/openbsd/networking/hostname.rb +18 -0
  36. data/lib/facter/facts/openbsd/networking/interfaces.rb +17 -0
  37. data/lib/facter/facts/openbsd/networking/ip.rb +18 -0
  38. data/lib/facter/facts/openbsd/networking/ip6.rb +18 -0
  39. data/lib/facter/facts/openbsd/networking/mac.rb +18 -0
  40. data/lib/facter/facts/openbsd/networking/mtu.rb +17 -0
  41. data/lib/facter/facts/openbsd/networking/netmask.rb +18 -0
  42. data/lib/facter/facts/openbsd/networking/netmask6.rb +18 -0
  43. data/lib/facter/facts/openbsd/networking/network.rb +18 -0
  44. data/lib/facter/facts/openbsd/networking/network6.rb +18 -0
  45. data/lib/facter/facts/openbsd/networking/primary.rb +17 -0
  46. data/lib/facter/facts/openbsd/networking/scope6.rb +17 -0
  47. data/lib/facter/facts/openbsd/os/architecture.rb +18 -0
  48. data/lib/facter/facts/openbsd/os/hardware.rb +18 -0
  49. data/lib/facter/facts/openbsd/os/name.rb +18 -0
  50. data/lib/facter/facts/openbsd/os/release.rb +23 -0
  51. data/lib/facter/facts/openbsd/path.rb +15 -0
  52. data/lib/facter/facts/openbsd/processors/isa.rb +17 -0
  53. data/lib/facter/facts/openbsd/ruby/platform.rb +18 -0
  54. data/lib/facter/facts/openbsd/ruby/sitedir.rb +18 -0
  55. data/lib/facter/facts/openbsd/ruby/version.rb +18 -0
  56. data/lib/facter/facts/openbsd/ssh.rb +26 -0
  57. data/lib/facter/facts/openbsd/sshalgorithmkey.rb +17 -0
  58. data/lib/facter/facts/openbsd/sshfp_algorithm.rb +20 -0
  59. data/lib/facter/facts/openbsd/system_uptime/days.rb +18 -0
  60. data/lib/facter/facts/openbsd/system_uptime/hours.rb +18 -0
  61. data/lib/facter/facts/openbsd/system_uptime/seconds.rb +18 -0
  62. data/lib/facter/facts/openbsd/system_uptime/uptime.rb +18 -0
  63. data/lib/facter/facts/openbsd/timezone.rb +15 -0
  64. data/lib/facter/facts/openbsd/virtual.rb +15 -0
  65. data/lib/facter/facts/solaris/ldom.rb +1 -1
  66. data/lib/facter/facts/windows/cloud/provider.rb +6 -3
  67. data/lib/facter/framework/cli/cli.rb +3 -3
  68. data/lib/facter/framework/core/file_loader.rb +59 -0
  69. data/lib/facter/framework/detector/os_detector.rb +2 -0
  70. data/lib/facter/framework/logging/logger.rb +3 -2
  71. data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
  72. data/lib/facter/resolvers/az.rb +1 -1
  73. data/lib/facter/resolvers/base_resolver.rb +3 -2
  74. data/lib/facter/resolvers/bsd/processors.rb +0 -1
  75. data/lib/facter/resolvers/disks.rb +0 -2
  76. data/lib/facter/resolvers/dmi.rb +0 -2
  77. data/lib/facter/resolvers/ec2.rb +1 -1
  78. data/lib/facter/resolvers/filesystems.rb +0 -2
  79. data/lib/facter/resolvers/fips_enabled.rb +0 -2
  80. data/lib/facter/resolvers/freebsd/processors.rb +0 -1
  81. data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
  82. data/lib/facter/resolvers/gce.rb +1 -1
  83. data/lib/facter/resolvers/hostname.rb +5 -0
  84. data/lib/facter/resolvers/identity.rb +0 -2
  85. data/lib/facter/resolvers/macosx/mountpoints.rb +0 -2
  86. data/lib/facter/resolvers/memory.rb +0 -2
  87. data/lib/facter/resolvers/mountpoints.rb +0 -2
  88. data/lib/facter/resolvers/networking.rb +1 -1
  89. data/lib/facter/resolvers/openbsd/dhcp.rb +21 -0
  90. data/lib/facter/resolvers/openbsd/dmi.rb +41 -0
  91. data/lib/facter/resolvers/openbsd/mountpoints.rb +72 -0
  92. data/lib/facter/resolvers/openbsd/virtual.rb +45 -0
  93. data/lib/facter/resolvers/partitions.rb +2 -2
  94. data/lib/facter/resolvers/processors.rb +0 -2
  95. data/lib/facter/resolvers/solaris/mountpoints.rb +0 -2
  96. data/lib/facter/resolvers/solaris/networking.rb +0 -1
  97. data/lib/facter/resolvers/ssh.rb +0 -2
  98. data/lib/facter/resolvers/windows/dmi_bios.rb +0 -1
  99. data/lib/facter/resolvers/windows/dmi_computersystem.rb +0 -1
  100. data/lib/facter/resolvers/windows/hardware_architecture.rb +0 -1
  101. data/lib/facter/resolvers/windows/identity.rb +0 -1
  102. data/lib/facter/resolvers/windows/kernel.rb +0 -2
  103. data/lib/facter/resolvers/windows/memory.rb +0 -2
  104. data/lib/facter/resolvers/windows/networking.rb +0 -1
  105. data/lib/facter/resolvers/windows/ssh.rb +0 -2
  106. data/lib/facter/resolvers/windows/system32.rb +0 -2
  107. data/lib/facter/resolvers/windows/timezone.rb +0 -1
  108. data/lib/facter/resolvers/windows/uptime.rb +0 -2
  109. data/lib/facter/resolvers/windows/virtualization.rb +9 -4
  110. data/lib/facter/resolvers/windows/win_os_description.rb +0 -2
  111. data/lib/facter/resolvers/xen.rb +2 -0
  112. data/lib/facter/templates/man.erb +5 -2
  113. data/lib/facter/util/api_debugger.rb +2 -2
  114. data/lib/facter/util/facts/posix/virtual_detector.rb +7 -1
  115. data/lib/facter/util/resolvers/http.rb +31 -20
  116. data/lib/facter/version.rb +1 -1
  117. metadata +99 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1942573c832a3213d49e5b9ed2181d183a796dd60bf21a02d42aef41d6a25257
4
- data.tar.gz: 0be877028bd3bf4181b988d1d643a65d7a16230c18b66b6aa1b1a5495c4eb050
3
+ metadata.gz: 512cdd220f22069dbf686592dfc08d3b4ecccf97702313117b333d5e568ebe8e
4
+ data.tar.gz: 373406fac7fe5ec363b13e6afa26acabfb6bb62716d9f0b977b1f2e768e6381d
5
5
  SHA512:
6
- metadata.gz: 5df0dff2bcdc8db67cd0aa4579c5b3f1d120a784557bb9de1cf7f6855b0bc88bd893cbfdbd1e07bf251a79f4ad3db6e94211240e34ac60b6935f0cf08e1d82e5
7
- data.tar.gz: 0627e49eb9f4f574847cf7923555eaf23703950ef9b947dab0c8885aec4005fd372587c6fbf4a1a22204756f84945ce675571ac0e224648804d0a16895c078a7
6
+ metadata.gz: ed2f2ac6dcec58364ba37df4acee50fb44f90f46f6de28f8f2524aa89d8d5634e7499be547234e65e4930126e59652b0d6b56f2d602e74598227d7808c504bf7
7
+ data.tar.gz: ef408018f71cd5884a56cf0dc3aab243fe119978e45c99e4b8069242d4ecf27011a3c106b53f12960665729bc0209aee452a02138e6642749f2c2b51e46a67bc
data/lib/docs/generate.rb CHANGED
@@ -17,7 +17,12 @@ def format_facts(fact_hash)
17
17
  scope = OpenStruct.new({
18
18
  facts: fact_hash
19
19
  })
20
- erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
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
21
26
  erb.result(scope.instance_eval { binding })
22
27
  end
23
28
 
data/lib/facter/config.rb CHANGED
@@ -44,8 +44,9 @@ module Facter
44
44
  ]
45
45
  },
46
46
  {
47
- 'Bsd' => [
48
- 'Freebsd'
47
+ 'Bsd' => %w[
48
+ Freebsd
49
+ Openbsd
49
50
  ]
50
51
  },
51
52
  'Solaris',
@@ -109,7 +109,7 @@ module Facter
109
109
  # @api private
110
110
  def evaluate(&block)
111
111
  if @last_evaluated
112
- msg = "Already evaluated #{@name}"
112
+ msg = +"Already evaluated #{@name}"
113
113
  msg << " at #{@last_evaluated}" if msg.is_a? String
114
114
  msg << ', reevaluating anyways'
115
115
  log.warn msg
@@ -197,6 +197,10 @@ module Facter
197
197
 
198
198
  private
199
199
 
200
+ def log
201
+ @log ||= Facter::Log.new(self)
202
+ end
203
+
200
204
  def evaluate_params(name)
201
205
  raise ArgumentError, "#{self.class.name}#chunk requires a block" unless block_given?
202
206
  raise ArgumentError, "#{self.class.name}#expected chunk name to be a Symbol" unless name.is_a? Symbol
@@ -35,7 +35,7 @@ module LegacyFacter
35
35
  end
36
36
 
37
37
  # Evaluate the fact, returning true or false.
38
- # if we have a block paramter then we only evaluate that instead
38
+ # if we have a block parameter then we only evaluate that instead
39
39
  def true?
40
40
  if @block && !@fact
41
41
  begin
@@ -54,9 +54,11 @@ module LegacyFacter
54
54
 
55
55
  return false if value.nil?
56
56
 
57
+ # We call the block with both the downcased and raw fact value for
58
+ # backwards-compatibility.
57
59
  if @block
58
60
  begin
59
- return !!@block.call(value)
61
+ return !!@block.call(value) || !!@block.call(fact.value) # rubocop:disable Style/DoubleNegation
60
62
  rescue StandardError => e
61
63
  log.debug "Confine raised #{e.class} #{e}"
62
64
  return false
@@ -9,11 +9,14 @@ module Facts
9
9
  def call_the_resolver
10
10
  provider = case Facter::Util::Facts::Posix::VirtualDetector.platform
11
11
  when 'hyperv'
12
- 'azure' unless Facter::Resolvers::Az.resolve(:metadata).empty?
12
+ metadata = Facter::Resolvers::Az.resolve(:metadata)
13
+ 'azure' unless metadata.nil? || metadata.empty?
13
14
  when 'kvm', 'xen'
14
- 'aws' unless Facter::Resolvers::Ec2.resolve(:metadata).empty?
15
+ metadata = Facter::Resolvers::Ec2.resolve(:metadata)
16
+ 'aws' unless metadata.nil? || metadata.empty?
15
17
  when 'gce'
16
- 'gce' unless Facter::Resolvers::Gce.resolve(:metadata).empty?
18
+ metadata = Facter::Resolvers::Gce.resolve(:metadata)
19
+ 'gce' unless metadata.nil? || metadata.empty?
17
20
  end
18
21
 
19
22
  Facter::ResolvedFact.new(FACT_NAME, provider)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Augeas
6
+ class Version
7
+ FACT_NAME = 'augeas.version'
8
+ ALIASES = 'augeasversion'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::Augeas.resolve(:augeas_version)
12
+
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value),
14
+ Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ module Bios
7
+ class Vendor
8
+ FACT_NAME = 'dmi.bios.vendor'
9
+ ALIASES = 'bios_vendor'
10
+
11
+ def call_the_resolver
12
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:bios_vendor)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ module Bios
7
+ class Version
8
+ FACT_NAME = 'dmi.bios.version'
9
+ ALIASES = 'bios_version'
10
+
11
+ def call_the_resolver
12
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:bios_version)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ class Manufacturer
7
+ FACT_NAME = 'dmi.manufacturer'
8
+ ALIASES = 'manufacturer'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:sys_vendor)
12
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ module Product
7
+ class Name
8
+ FACT_NAME = 'dmi.product.name'
9
+ ALIASES = 'productname'
10
+
11
+ def call_the_resolver
12
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_name)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ module Product
7
+ class SerialNumber
8
+ FACT_NAME = 'dmi.product.serial_number'
9
+ ALIASES = 'serialnumber'
10
+
11
+ def call_the_resolver
12
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_serial)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Dmi
6
+ module Product
7
+ class Uuid
8
+ FACT_NAME = 'dmi.product.uuid'
9
+ ALIASES = 'uuid'
10
+
11
+ def call_the_resolver
12
+ fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_uuid)
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Ec2Metadata
6
+ FACT_NAME = 'ec2_metadata'
7
+
8
+ def call_the_resolver
9
+ return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors?
10
+
11
+ fact_value = Facter::Resolvers::Ec2.resolve(:metadata)
12
+
13
+ Facter::ResolvedFact.new(FACT_NAME, fact_value&.empty? ? nil : fact_value)
14
+ end
15
+
16
+ private
17
+
18
+ def aws_hypervisors?
19
+ Facter::Util::Facts::Posix::VirtualDetector.platform =~ /kvm|xen|aws/
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Ec2Userdata
6
+ FACT_NAME = 'ec2_userdata'
7
+
8
+ def call_the_resolver
9
+ return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors?
10
+
11
+ fact_value = Facter::Resolvers::Ec2.resolve(:userdata)
12
+
13
+ Facter::ResolvedFact.new(FACT_NAME, fact_value&.empty? ? nil : fact_value)
14
+ end
15
+
16
+ private
17
+
18
+ def aws_hypervisors?
19
+ Facter::Util::Facts::Posix::VirtualDetector.platform =~ /kvm|xen|aws/
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Facterversion
6
+ FACT_NAME = 'facterversion'
7
+
8
+ def call_the_resolver
9
+ fact_value = Facter::Resolvers::Facterversion.resolve(:facterversion)
10
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Identity
6
+ class Gid
7
+ FACT_NAME = 'identity.gid'
8
+
9
+ def call_the_resolver
10
+ fact_value = Facter::Resolvers::PosxIdentity.resolve(:gid)
11
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Identity
6
+ class Group
7
+ FACT_NAME = 'identity.group'
8
+ ALIASES = 'gid'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::PosxIdentity.resolve(:group)
12
+
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Identity
6
+ class Privileged
7
+ FACT_NAME = 'identity.privileged'
8
+
9
+ def call_the_resolver
10
+ fact_value = Facter::Resolvers::PosxIdentity.resolve(:privileged)
11
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Identity
6
+ class Uid
7
+ FACT_NAME = 'identity.uid'
8
+
9
+ def call_the_resolver
10
+ fact_value = Facter::Resolvers::PosxIdentity.resolve(:uid)
11
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Identity
6
+ class User
7
+ FACT_NAME = 'identity.user'
8
+ ALIASES = 'id'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::PosxIdentity.resolve(:user)
12
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Ipaddress6Interfaces
6
+ FACT_NAME = 'ipaddress6_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("ipaddress6_#{interface_name}", info[:ip6], :legacy) if info[:ip6]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class IpaddressInterfaces
6
+ FACT_NAME = 'ipaddress_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("ipaddress_#{interface_name}", info[:ip], :legacy) if info[:ip]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class IsVirtual
6
+ FACT_NAME = 'is_virtual'
7
+
8
+ def call_the_resolver
9
+ fact_value = Facter::Util::Facts::Posix::VirtualDetector.platform
10
+
11
+ Facter::ResolvedFact.new(FACT_NAME, check_if_virtual(fact_value))
12
+ end
13
+
14
+ private
15
+
16
+ def check_if_virtual(found_vm)
17
+ Facter::Util::Facts::PHYSICAL_HYPERVISORS.count(found_vm).zero?
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Kernel
6
+ FACT_NAME = 'kernel'
7
+
8
+ def call_the_resolver
9
+ fact_value = Facter::Resolvers::Uname.resolve(:kernelname)
10
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Kernelrelease
6
+ FACT_NAME = 'kernelrelease'
7
+
8
+ def call_the_resolver
9
+ fact_value = Facter::Resolvers::Uname.resolve(:kernelrelease)
10
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Mountpoints
6
+ FACT_NAME = 'mountpoints'
7
+
8
+ def call_the_resolver
9
+ mountpoints = Facter::Resolvers::Openbsd::Mountpoints.resolve(FACT_NAME.to_sym)
10
+ return Facter::ResolvedFact.new(FACT_NAME, nil) unless mountpoints
11
+
12
+ fact = {}
13
+ mountpoints.each do |path, mnt|
14
+ fact[path.to_sym] = mnt.reject { |k| k == :path }
15
+ end
16
+
17
+ Facter::ResolvedFact.new(FACT_NAME, fact)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Netmask6Interfaces
6
+ FACT_NAME = 'netmask6_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("netmask6_#{interface_name}", info[:netmask6], :legacy) if info[:netmask6]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class NetmaskInterfaces
6
+ FACT_NAME = 'netmask_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("netmask_#{interface_name}", info[:netmask], :legacy) if info[:netmask]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class Network6Interfaces
6
+ FACT_NAME = 'network6_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("network6_#{interface_name}", info[:network6], :legacy) if info[:network6]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ class NetworkInterfaces
6
+ FACT_NAME = 'network_.*'
7
+ TYPE = :legacy
8
+
9
+ def call_the_resolver
10
+ arr = []
11
+ interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
12
+ interfaces&.each do |interface_name, info|
13
+ arr << Facter::ResolvedFact.new("network_#{interface_name}", info[:network], :legacy) if info[:network]
14
+ end
15
+
16
+ arr
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Networking
6
+ class Dhcp
7
+ FACT_NAME = 'networking.dhcp'
8
+
9
+ def call_the_resolver
10
+ fact_value = Facter::Resolvers::Openbsd::Dhcp.resolve(:dhcp)
11
+
12
+ Facter::ResolvedFact.new(FACT_NAME, fact_value)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Networking
6
+ class Domain
7
+ FACT_NAME = 'networking.domain'
8
+ ALIASES = 'domain'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::Hostname.resolve(:domain)
12
+
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facts
4
+ module Openbsd
5
+ module Networking
6
+ class Fqdn
7
+ FACT_NAME = 'networking.fqdn'
8
+ ALIASES = 'fqdn'
9
+
10
+ def call_the_resolver
11
+ fact_value = Facter::Resolvers::Hostname.resolve(:fqdn)
12
+
13
+ [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end