Skip to content

Commit

Permalink
Fix 'virtual' fact on FreeBSD
Browse files Browse the repository at this point in the history
We should not call Linux-specific code from a non-Linux system.  This
cross-platform utility class needs to skip Linux code when running on a
non-linux platform.
  • Loading branch information
smortex committed Jul 30, 2024
1 parent f4bbdd3 commit 12e3a72
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/facter/util/facts/posix/virtual_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ def platform
private

def check_docker_lxc
return nil unless const_defined?('Facter::Resolvers::Linux')

Facter::Resolvers::Linux::Containers.resolve(:vm)
end

def check_gce
return nil unless const_defined?('Facter::Resolvers::Linux')

bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
'gce' if bios_vendor&.include?('Google')
end
Expand Down Expand Up @@ -61,6 +65,8 @@ def check_openbsd
end

def check_other_facts
return nil unless const_defined?('Facter::Resolvers::Linux')

bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
return 'kvm' if bios_vendor&.include?('Amazon EC2')

Expand Down

0 comments on commit 12e3a72

Please sign in to comment.