# Debugging 'setup' python script

**URL:** <https://forum.ansible.com/t/debugging-setup-python-script/11644>\
**Category:** Ansible Project\
**Created:** [July 4, 2012, 9:58am UTC](https://forum.ansible.com/t/debugging-setup-python-script/11644 "2012-07-04T09:58:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harm\_Aarts](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@Harm\_Aarts](https://forum.ansible.com/u/Harm_Aarts)\
**Post date:** [July 4, 2012, 9:58am UTC](https://forum.ansible.com/t/debugging-setup-python-script/11644/1 "2012-07-04T09:58:44Z")

</div>

Hi,

I’m trying to use Ansible to setup a Raspberry Pi. Somewhere during the “setup phase” an exception is thrown:

fatal: [192.168.x.x] =\> failed to parse: Traceback (most recent call last):

File “/home/pi/.ansible/tmp/ansible-1341394591.63-194378702522991/setup”, line 351, in

for (k, v) in ansible\_facts().items():

File “/home/pi/.ansible/tmp/ansible-1341394591.63-194378702522991/setup”, line 307, in ansible\_facts

get\_virtual\_facts(facts)

File “/home/pi/.ansible/tmp/ansible-1341394591.63-194378702522991/setup”, line 211, in get\_virtual\_facts

facts = get\_linux\_virtual\_facts(facts)

File “/home/pi/.ansible/tmp/ansible-1341394591.63-194378702522991/setup”, line 191, in get\_linux\_virtual\_facts

if ‘QEMU’ in facts[‘processor’][0]:

KeyError: ‘processor’

I’m now wondering how I could debug this problem. I can log in to the Pi and I do have the setup file. But I don’t know how to proceed from there. I have tried loading the file and calling a function like so:  
$ python -c ‘import imp; setup = imp.load\_source(“setup”, “/home/pi/.ansible/tmp/ansible-1341394591.63-194378702522991/setup”); print setup.ansible\_facts();’

To no avail. Could someone point me in the right direction?

With kind regards,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 4, 2012, 12:35pm UTC](https://forum.ansible.com/t/debugging-setup-python-script/11644/2 "2012-07-04T12:35:19Z")

</div>

The problem is (at least in) in the get\_cpu\_facts function because various files in /proc being substantially different than the OSes people are using Ansible on already.

(I'm not surprised, first time I've heard anyone using Ansible on a Pi.)

Shouldn't be hard to fix, you may wish to try checking out the ansible source on your Pi (or rsync the files, etc) and run ./hacking/test-module to iterate over the setup module until it works  
completely. I don't have access to a Pi, so you're probably the best one to do it!

Having it detect the distribution and deciding not to do certain parts of the fact code is probably fine -- I am guessing you don't need many of the variables that it generates at all.

(For what it's worth, when you say you "have" the setup file, you have the module, but you don't have the output, because it didn't run successfully)
