Skip to content

Commit

Permalink
(maint) Rework the OS families hierarchy (#2019)
Browse files Browse the repository at this point in the history
Solaris > BSD > FreeBSD OS hierarchy was convenient to some point but is
inaccurate and starts to be a pain (e.g. networking facts depends on
types only known to Solaris, breaking FFI on FreeBSD).

Move BSD at the same level of the Solaris OS in the hierarchy.  This
makes quite a lot of facts disapear, but it allows us to re-introduce
them without side-effects from the Solaris facts and remove cruft added
to hide facts that make no sense on FreeBSD.
  • Loading branch information
smortex authored Aug 14, 2020
1 parent 5619fa9 commit 473932b
Show file tree
Hide file tree
Showing 227 changed files with 2,894 additions and 602 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ RSpec/FilePath:
- 'spec/facter/resolvers/solaris/solaris_release_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/solaris_zone_name_spec.rb'
- 'spec/facter/resolvers/solaris/zone_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zpool_resolver_spec.rb'
- 'spec/facter/resolvers/suse_relese_resolver_spec.rb'
- 'spec/facter/resolvers/system_profile_resolver_spec.rb'
- 'spec/facter/resolvers/utils/aix/odm_query_spec.rb'
Expand All @@ -72,6 +71,7 @@ RSpec/FilePath:
- 'spec/facter/resolvers/windows/system32_resolver_spec.rb'
- 'spec/facter/resolvers/windows/virtualization_resolver_spec.rb'
- 'spec/facter/resolvers/windows/win_os_description_resolver_spec.rb'
- 'spec/facter/resolvers/zpool_resolver_spec.rb'
- 'spec/framework/config/config_reader_spec.rb'
- 'spec/framework/config/fact_groups_spec.rb'
- 'spec/framework/core/fact/external/external_fact_manager_spec.rb'
Expand Down
19 changes: 19 additions & 0 deletions lib/facter/facts/freebsd/augeas/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Augeas
class Version
FACT_NAME = 'augeas.version'
ALIASES = 'augeasversion'

def call_the_resolver
fact_value = Facter::Resolvers::Augeas.resolve(:augeas_version)

[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
14 changes: 14 additions & 0 deletions lib/facter/facts/freebsd/facterversion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Facterversion
FACT_NAME = 'facterversion'

def call_the_resolver
fact_value = Facter::Resolvers::Facterversion.resolve(:facterversion)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
16 changes: 16 additions & 0 deletions lib/facter/facts/freebsd/identity/gid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Identity
class Gid
FACT_NAME = 'identity.gid'

def call_the_resolver
fact_value = Facter::Resolvers::PosxIdentity.resolve(:gid)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
18 changes: 18 additions & 0 deletions lib/facter/facts/freebsd/identity/group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Identity
class Group
FACT_NAME = 'identity.group'
ALIASES = 'gid'

def call_the_resolver
fact_value = Facter::Resolvers::PosxIdentity.resolve(:group)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
16 changes: 16 additions & 0 deletions lib/facter/facts/freebsd/identity/privileged.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Identity
class Privileged
FACT_NAME = 'identity.privileged'

def call_the_resolver
fact_value = Facter::Resolvers::PosxIdentity.resolve(:privileged)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
16 changes: 16 additions & 0 deletions lib/facter/facts/freebsd/identity/uid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Identity
class Uid
FACT_NAME = 'identity.uid'

def call_the_resolver
fact_value = Facter::Resolvers::PosxIdentity.resolve(:uid)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/facter/facts/freebsd/identity/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Identity
class User
FACT_NAME = 'identity.user'
ALIASES = 'id'

def call_the_resolver
fact_value = Facter::Resolvers::PosxIdentity.resolve(:user)
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
14 changes: 14 additions & 0 deletions lib/facter/facts/freebsd/kernel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Kernel
FACT_NAME = 'kernel'

def call_the_resolver
fact_value = Facter::Resolvers::Uname.resolve(:kernelname)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
14 changes: 14 additions & 0 deletions lib/facter/facts/freebsd/kernelrelease.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Kernelrelease
FACT_NAME = 'kernelrelease'

def call_the_resolver
fact_value = Facter::Resolvers::Uname.resolve(:kernelrelease)
Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
21 changes: 21 additions & 0 deletions lib/facter/facts/freebsd/mountpoints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Mountpoints
FACT_NAME = 'mountpoints'

def call_the_resolver
mountpoints = Facter::Resolvers::Mountpoints.resolve(FACT_NAME.to_sym)
return Facter::ResolvedFact.new(FACT_NAME, nil) unless mountpoints

fact = {}
mountpoints.each do |mnt|
fact[mnt[:path].to_sym] = mnt.reject { |k| k == :path }
end

Facter::ResolvedFact.new(FACT_NAME, fact)
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/freebsd/netmask6_interfaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Netmask6Interfaces
FACT_NAME = 'netmask6_.*'
TYPE = :legacy

def call_the_resolver
arr = []
interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
interfaces&.each do |interface_name, info|
arr << Facter::ResolvedFact.new("netmask6_#{interface_name}", info[:netmask6], :legacy) if info[:netmask6]
end

arr
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/freebsd/netmask_interfaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Freebsd
class NetmaskInterfaces
FACT_NAME = 'netmask_.*'
TYPE = :legacy

def call_the_resolver
arr = []
interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
interfaces&.each do |interface_name, info|
arr << Facter::ResolvedFact.new("netmask_#{interface_name}", info[:netmask], :legacy) if info[:netmask]
end

arr
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/freebsd/network6_interfaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Freebsd
class Network6Interfaces
FACT_NAME = 'network6_.*'
TYPE = :legacy

def call_the_resolver
arr = []
interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
interfaces&.each do |interface_name, info|
arr << Facter::ResolvedFact.new("network6_#{interface_name}", info[:network6], :legacy) if info[:network6]
end

arr
end
end
end
end
20 changes: 20 additions & 0 deletions lib/facter/facts/freebsd/network_interfaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Facts
module Freebsd
class NetworkInterfaces
FACT_NAME = 'network_.*'
TYPE = :legacy

def call_the_resolver
arr = []
interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
interfaces&.each do |interface_name, info|
arr << Facter::ResolvedFact.new("network_#{interface_name}", info[:network], :legacy) if info[:network]
end

arr
end
end
end
end
17 changes: 17 additions & 0 deletions lib/facter/facts/freebsd/networking/dhcp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Dhcp
FACT_NAME = 'networking.dhcp'

def call_the_resolver
fact_value = Facter::Resolvers::Networking.resolve(:dhcp)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
18 changes: 18 additions & 0 deletions lib/facter/facts/freebsd/networking/domain.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Domain
FACT_NAME = 'networking.domain'
ALIASES = 'domain'

def call_the_resolver
fact_value = Facter::Resolvers::Hostname.resolve(:domain)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
18 changes: 18 additions & 0 deletions lib/facter/facts/freebsd/networking/fqdn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Fqdn
FACT_NAME = 'networking.fqdn'
ALIASES = 'fqdn'

def call_the_resolver
fact_value = Facter::Resolvers::Hostname.resolve(:fqdn)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
18 changes: 18 additions & 0 deletions lib/facter/facts/freebsd/networking/hostname.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Hostname
FACT_NAME = 'networking.hostname'
ALIASES = 'hostname'

def call_the_resolver
fact_value = Facter::Resolvers::Hostname.resolve(:hostname)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/facter/facts/freebsd/networking/interfaces.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Interfaces
FACT_NAME = 'networking.interfaces'

def call_the_resolver
fact_value = Facter::Resolvers::Networking.resolve(:interfaces)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
end
end
end
end
end
18 changes: 18 additions & 0 deletions lib/facter/facts/freebsd/networking/ip.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Facts
module Freebsd
module Networking
class Ip
FACT_NAME = 'networking.ip'
ALIASES = 'ipaddress'

def call_the_resolver
fact_value = Facter::Resolvers::Networking.resolve(:ip)

[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)]
end
end
end
end
end
Loading

0 comments on commit 473932b

Please sign in to comment.