1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix setup module to gather facts from PowerPC Macs.

This commit is contained in:
Chris Church 2014-02-25 18:27:36 -05:00
parent ca78657538
commit 1d6bdd451b

View file

@ -1359,14 +1359,30 @@ class Darwin(Hardware):
sysctl[key] = value.strip() sysctl[key] = value.strip()
return sysctl return sysctl
def get_system_profile(self):
rc, out, err = module.run_command(["/usr/sbin/system_profiler", "SPHardwareDataType"])
if rc != 0:
return dict()
system_profile = dict()
for line in out.splitlines():
if ': ' in line:
(key, value) = line.split(': ', 1)
system_profile[key.strip()] = ' '.join(value.strip().split())
return system_profile
def get_mac_facts(self): def get_mac_facts(self):
self.facts['model'] = self.sysctl['hw.model'] self.facts['model'] = self.sysctl['hw.model']
self.facts['osversion'] = self.sysctl['kern.osversion'] self.facts['osversion'] = self.sysctl['kern.osversion']
self.facts['osrevision'] = self.sysctl['kern.osrevision'] self.facts['osrevision'] = self.sysctl['kern.osrevision']
def get_cpu_facts(self): def get_cpu_facts(self):
self.facts['processor'] = self.sysctl['machdep.cpu.brand_string'] if 'machdep.cpu.brand_string' in self.sysctl: # Intel
self.facts['processor_cores'] = self.sysctl['machdep.cpu.core_count'] self.facts['processor'] = self.sysctl['machdep.cpu.brand_string']
self.facts['processor_cores'] = self.sysctl['machdep.cpu.core_count']
else: # PowerPC
system_profile = self.get_system_profile()
self.facts['processor'] = '%s @ %s' % (system_profile['Processor Name'], system_profile['Processor Speed'])
self.facts['processor_cores'] = self.sysctl['hw.physicalcpu']
def get_memory_facts(self): def get_memory_facts(self):
self.facts['memtotal_mb'] = long(self.sysctl['hw.memsize']) / 1024 / 1024 self.facts['memtotal_mb'] = long(self.sysctl['hw.memsize']) / 1024 / 1024