-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2642 from buzzdeee/master
(FACT-3163) Add support for OpenBSD
- Loading branch information
Showing
130 changed files
with
3,405 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,9 @@ module Config | |
] | ||
}, | ||
{ | ||
'Bsd' => [ | ||
'Freebsd' | ||
'Bsd' => %w[ | ||
Freebsd | ||
Openbsd | ||
] | ||
}, | ||
'Solaris', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
module Bios | ||
class Vendor | ||
FACT_NAME = 'dmi.bios.vendor' | ||
ALIASES = 'bios_vendor' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:bios_vendor) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
module Bios | ||
class Version | ||
FACT_NAME = 'dmi.bios.version' | ||
ALIASES = 'bios_version' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:bios_version) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
class Manufacturer | ||
FACT_NAME = 'dmi.manufacturer' | ||
ALIASES = 'manufacturer' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:sys_vendor) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
module Product | ||
class Name | ||
FACT_NAME = 'dmi.product.name' | ||
ALIASES = 'productname' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_name) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
module Product | ||
class SerialNumber | ||
FACT_NAME = 'dmi.product.serial_number' | ||
ALIASES = 'serialnumber' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_serial) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
module Dmi | ||
module Product | ||
class Uuid | ||
FACT_NAME = 'dmi.product.uuid' | ||
ALIASES = 'uuid' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Resolvers::Openbsd::DmiBios.resolve(:product_uuid) | ||
[Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
class Ec2Metadata | ||
FACT_NAME = 'ec2_metadata' | ||
|
||
def call_the_resolver | ||
return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors? | ||
|
||
fact_value = Facter::Resolvers::Ec2.resolve(:metadata) | ||
|
||
Facter::ResolvedFact.new(FACT_NAME, fact_value&.empty? ? nil : fact_value) | ||
end | ||
|
||
private | ||
|
||
def aws_hypervisors? | ||
Facter::Util::Facts::Posix::VirtualDetector.platform =~ /kvm|xen|aws/ | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
class Ec2Userdata | ||
FACT_NAME = 'ec2_userdata' | ||
|
||
def call_the_resolver | ||
return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors? | ||
|
||
fact_value = Facter::Resolvers::Ec2.resolve(:userdata) | ||
|
||
Facter::ResolvedFact.new(FACT_NAME, fact_value&.empty? ? nil : fact_value) | ||
end | ||
|
||
private | ||
|
||
def aws_hypervisors? | ||
Facter::Util::Facts::Posix::VirtualDetector.platform =~ /kvm|xen|aws/ | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
class Ipaddress6Interfaces | ||
FACT_NAME = 'ipaddress6_.*' | ||
TYPE = :legacy | ||
|
||
def call_the_resolver | ||
arr = [] | ||
interfaces = Facter::Resolvers::Networking.resolve(:interfaces) | ||
interfaces&.each do |interface_name, info| | ||
arr << Facter::ResolvedFact.new("ipaddress6_#{interface_name}", info[:ip6], :legacy) if info[:ip6] | ||
end | ||
|
||
arr | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
class IpaddressInterfaces | ||
FACT_NAME = 'ipaddress_.*' | ||
TYPE = :legacy | ||
|
||
def call_the_resolver | ||
arr = [] | ||
interfaces = Facter::Resolvers::Networking.resolve(:interfaces) | ||
interfaces&.each do |interface_name, info| | ||
arr << Facter::ResolvedFact.new("ipaddress_#{interface_name}", info[:ip], :legacy) if info[:ip] | ||
end | ||
|
||
arr | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
class IsVirtual | ||
FACT_NAME = 'is_virtual' | ||
|
||
def call_the_resolver | ||
fact_value = Facter::Util::Facts::Posix::VirtualDetector.platform | ||
|
||
Facter::ResolvedFact.new(FACT_NAME, check_if_virtual(fact_value)) | ||
end | ||
|
||
private | ||
|
||
def check_if_virtual(found_vm) | ||
Facter::Util::Facts::PHYSICAL_HYPERVISORS.count(found_vm).zero? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facts | ||
module Openbsd | ||
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 |
Oops, something went wrong.