Bug #1838

Facter fails with errors on VMware virtualized OS X server hosts.

Added by Teyo Tyree over 3 years ago. Updated about 2 years ago.

Status:Closed Start date:12/23/2008
Priority:High Due date:
Assignee:Luke Kanies % Done:

0%

Category:-
Target version:1.5.3
Keywords:customer_reported Affected Facter version:
Branch:
Votes: 0

Description

It seems facter won’t run in virtual environment if the OS is Mac OS X. After installing puppet and facter version 0.24.7 using gems and Mac packages, I can’t get facter to run. I get this error:

sh-3.2# facter
2008-12-22 11:58:06.223 system_profiler[6613:10b] Exception while calling [SPPlatformReporter updateDictionary:]
*** -[NSCFArray objectAtIndex:]: index (3) beyond bounds (2)
/Library/Ruby/Site/1.8/facter/util/macosx.rb:29:in `hardware_overview': undefined method `[]' for nil:NilClass (NoMethodError)
from /Library/Ruby/Site/1.8/facter/macosx.rb:28
from /Library/Ruby/Site/1.8/facter/util/loader.rb:72:in `load'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:72:in `load_file'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:38:in `load_all'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:33:in `each'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:33:in `load_all'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:30:in `each'
from /Library/Ruby/Site/1.8/facter/util/loader.rb:30:in `load_all'
from /Library/Ruby/Site/1.8/facter/util/collection.rb:90:in `load_all'
from /Library/Ruby/Site/1.8/facter.rb:91:in `to_hash'
from /usr/bin/facter:121

Nigel posted the following work around to the list.

# /usr/lib/ruby/site_ruby/1.8/facter/util/macosx.rb

def self.hardware_overview
# JJM Perhaps we should cache the XML data in a "class" level object.
top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml SPHardwareDataType}
system_hardware = {}
begin
system_hardware = top_level_plist[0]['_items'][0]
system_hardware.delete '_name'
rescue
# do nothing
end
system_hardware
end 

The failure is a result of this Vmware bug, http://communities.vmware.com/message/1130391 but Facter should not fail if it is unable to gather hardware information from the system profiler. Nigel’s work around addresses this issue.

History

Updated by Luke Kanies over 3 years ago

  • Status changed from Unreviewed to Accepted

Updated by Luke Kanies over 3 years ago

  • Target version set to 1.5.3

Updated by Luke Kanies over 3 years ago

It seems like something like this would be a better solution:

def self.hardware_overview
  top_level_plist = Plist::parse_xml %x{/usr/sbin/system_profiler -xml SPHardwareDataType}
  return nil unless top_level_plist[0].include?('_items')
  system_hardware = {}
  system_hardware = top_level_plist[0]['_items'][0]
  system_hardware.delete '_name'
  system_hardware
end 

I don’t know where it’s actually failing, so I don’t know which array or has you should be checking, but this style seems like a cleaner and more obvious solution. Can someone with the problem test this and make sure it works?

Updated by Luke Kanies over 3 years ago

  • Status changed from Accepted to Ready For Checkin

Fixed in the tickets/master/1838 branch in my repo. I’ll probably just merge it myself after fixing the other few open tickets for this release.

Updated by Luke Kanies over 3 years ago

  • Status changed from Ready For Checkin to Closed

Merged into master; the main commit is commit:1f1fa9bcecfb6d137219819c9aeefdc41f3f9dce.

Nope, I didn’t give long to test.

Also available in: Atom PDF