diff --git a/lib/facter/util/facts/posix/virtual_detector.rb b/lib/facter/util/facts/posix/virtual_detector.rb index 80a3c98b11..ff2c56a6f7 100644 --- a/lib/facter/util/facts/posix/virtual_detector.rb +++ b/lib/facter/util/facts/posix/virtual_detector.rb @@ -8,9 +8,9 @@ module VirtualDetector class << self def platform @fact_value ||= # rubocop:disable Naming/MemoizedInstanceVariableName - check_docker_lxc || check_freebsd || check_gce || retrieve_from_virt_what || \ - check_vmware || check_open_vz || check_vserver || check_xen || check_other_facts || \ - check_lspci || 'physical' + check_docker_lxc || check_freebsd || check_gce || check_illumos_lx || \ + retrieve_from_virt_what || check_vmware || check_open_vz || check_vserver || \ + check_xen || check_other_facts || check_lspci || 'physical' end private @@ -24,6 +24,10 @@ def check_gce 'gce' if bios_vendor&.include?('Google') end + def check_illumos_lx + 'illumos-lx' if Facter::Resolvers::Uname.resolve(:kernelversion) == 'BrandZ virtual linux' + end + def check_vmware Facter::Resolvers::Vmware.resolve(:vm) end diff --git a/spec/facter/util/facts/posix/virtual_detector_spec.rb b/spec/facter/util/facts/posix/virtual_detector_spec.rb index 23366d9d44..88903d000b 100644 --- a/spec/facter/util/facts/posix/virtual_detector_spec.rb +++ b/spec/facter/util/facts/posix/virtual_detector_spec.rb @@ -241,6 +241,19 @@ end end + context 'when illumos-lx' do + let(:value) { 'illumos-lx' } + + before do + allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return('lxc') + allow(Facter::Resolvers::Uname).to receive(:resolve).with(:kernelversion).and_return('BrandZ virtual linux') + end + + it 'returns illumos-lx' do + expect(detector.platform).to eq(value) + end + end + context 'when all resolvers return nil ' do let(:vm) { 'physical' }