Skip to content

Instantly share code, notes, and snippets.

@nkryptic
Last active August 29, 2015 14:08
Show Gist options
  • Save nkryptic/3a370e334e00038d8611 to your computer and use it in GitHub Desktop.
Save nkryptic/3a370e334e00038d8611 to your computer and use it in GitHub Desktop.
require 'facter'
Facter.add(:esxi_version) do
confine :virtual => :vmware
confine :kernel => :Linux
setcode do
dmi_path = Facter::Util::Resolution.exec('which dmidecode 2> /dev/null')
if dmi_path.nil?
'unknown:no_dmidecode'
else
bios_output = Facter::Util::Resolution.exec("#{dmi_path} -t bios 2> /dev/null")
if bios_output.nil?
'unknown:dmidecode_empty_output'
else
bios_address = bios_output.match(/Address: 0x(?<addr>.*)/i)
if bios_address.nil?
'unknown:dmidecode_parsing_error'
else
case bios_address[:addr]
when 'E72C0'
'5.0'
when 'EA0C0'
'5.1'
when 'EA050'
'5.5'
else
"unknown:unrecognized_bios_address:#{bios_address}"
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment