# inventory broken on old PowerPC Mac

**URL:** <https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655>\
**Category:** Ansible Developer\
**Created:** [February 25, 2014, 10:01pm UTC](https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655 "2014-02-25T22:01:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabrice.gaillard](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fabrice.gaillard](https://forum.ansible.com/u/fabrice.gaillard)\
**Post date:** [February 25, 2014, 10:01pm UTC](https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655/1 "2014-02-25T22:01:40Z")

</div>

Hello,

I’v found a small bug in inventory when running the inventory on old power PC machintosh :

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [[ns2.p2pweb.net](http://ns2.p2pweb.net)] =\> failed to parse: Traceback (most recent call last):  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 3417, in   
main()  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 2342, in main  
data = run\_setup(module)  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 2283, in run\_setup  
facts = ansible\_facts()  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 2273, in ansible\_facts  
facts.update(Hardware().populate())  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 1347, in populate  
self.get\_cpu\_facts()  
File “/Users/fabrice/.ansible/tmp/ansible-tmp-1393363917.68-153393865171475/setup”, line 1369, in get\_cpu\_facts  
self.facts[‘processor’] = self.sysctl[‘machdep.cpu.brand\_string’]  
KeyError: ‘machdep.cpu.brand\_string’

The problem is that on powerPC machines, sysctl doesn’t know about machdep.

Instead, you may use : ‘hw.model’ and ‘hw.ncpu’

This can be corrected in the file library/system/setup with something like that :

class Darwin(Hardware):  
“”"  
Darwin-specific subclass of Hardware. Defines memory and CPU facts:

- processor
- processor\_cores
- memtotal\_mb
- memfree\_mb
- model
- osversion
- osrevision  
“”"  
platform = ‘Darwin’

def **init** (self):  
Hardware. **init** (self)

def populate(self):  
self.sysctl = self.get\_sysctl()  
self.get\_mac\_facts()  
self.get\_cpu\_facts()  
self.get\_memory\_facts()  
return self.facts

def get\_sysctl(self):  
rc, out, err = module.run\_command([“/usr/sbin/sysctl”, “hw”, “machdep”, “kern”])  
if rc != 0:  
return dict()  
sysctl = dict()  
for line in out.splitlines():  
if line.rstrip(“\n”):  
(key, value) = re.split(’ = |: ', line, maxsplit=1)  
sysctl[key] = value.strip()  
return sysctl

def get\_mac\_facts(self):  
self.facts[‘model’] = self.sysctl[‘hw.model’]  
self.facts[‘osversion’] = self.sysctl[‘kern.osversion’]  
self.facts[‘osrevision’] = self.sysctl[‘kern.osrevision’]

def get\_cpu\_facts(self):

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 25, 2014, 10:18pm UTC](https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655/2 "2014-02-25T22:18:04Z")

</div>

Thanks for the report, can you please file this on github so we don’t lose track?

Much appreciated!

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [February 25, 2014, 11:44pm UTC](https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655/3 "2014-02-25T23:44:18Z")

</div>

I knew I’d find a reason for keeping the old G5 around.

---

<div class="post-metadata">

**Author:** ![fabrice.gaillard](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fabrice.gaillard](https://forum.ansible.com/u/fabrice.gaillard)\
**Post date:** [March 6, 2014, 11:44am UTC](https://forum.ansible.com/t/inventory-broken-on-old-powerpc-mac/14655/4 "2014-03-06T11:44:02Z")

</div>

Hi,

My code was just a quick fix, and you solution is clearly better

Thanks

–fabrice
