# Debugging setup problems

**URL:** <https://forum.ansible.com/t/debugging-setup-problems/11750>\
**Category:** Ansible Project\
**Created:** [August 2, 2012, 11:05am UTC](https://forum.ansible.com/t/debugging-setup-problems/11750 "2012-08-02T11:05:06Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 11:05am UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/1 "2012-08-02T11:05:06Z")

</div>

I have a playbook that looks like this:

----8\<-- playbook --8\<----

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 11:39am UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/2 "2012-08-02T11:39:03Z")

</div>

Worth nothing is I can't seem to replicate the error on any host not running rhel6.3 so is there a syntax change in python-2.6.6-29.el6\_2.2.x86\_64??

/andreas

---

<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:** [August 2, 2012, 11:44am UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/3 "2012-08-02T11:44:28Z")

</div>

There's no Python syntax change or problem with Python, rather this module is just not happy on RHEL 6.3 -- probably because there's a new form factor and the array isn't long enough. This is a module bug, as here is the code:

&nbsp;&nbsp;&nbsp;# From smolt and DMI spec  
FORM\_FACTOR = [ "Unknown", "Other", "Unknown", "Desktop",  
"Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower",  
"Portable", "Laptop", "Notebook", "Hand Held", "Docking Station",  
"All In One", "Sub Notebook", "Space-saving", "Lunch Box",  
"Main Server Chassis", "Expansion Chassis", "Sub Chassis",  
"Bus Expansion Chassis", "Peripheral Chassis", "RAID Chassis",  
"Rack Mount Chassis", "Sealed-case PC", "Multi-system",  
"CompactPCI", "AdvancedTCA" ]

You can debug this on the remote system using an ansible checkout there and ./hacking/test-module -m setup

If you put in a print to show the int(data) value, what do you get?

Either way the module needs to try/except around this at least, such that if it can't figure out the form factor nothing bad happens and the setup module is still  
successful, and I'll file a bug about this.

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 11:59am UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/4 "2012-08-02T11:59:46Z")

</div>

> There's no Python syntax change or problem with Python, rather this  
> module is just not happy on RHEL 6.3 -- probably because there's a  
> new form factor and the array isn't long enough. This is a module  
> bug, as here is the code:
> 
> &nbsp;&nbsp;&nbsp;# From smolt and DMI spec  
> FORM\_FACTOR = [ "Unknown", "Other", "Unknown", "Desktop",  
> "Low Profile Desktop", "Pizza Box", "Mini Tower", "Tower",  
> "Portable", "Laptop", "Notebook", "Hand Held", "Docking Station",  
> "All In One", "Sub Notebook", "Space-saving", "Lunch Box",  
> "Main Server Chassis", "Expansion Chassis", "Sub Chassis",  
> "Bus Expansion Chassis", "Peripheral Chassis", "RAID Chassis",  
> "Rack Mount Chassis", "Sealed-case PC", "Multi-system",  
> "CompactPCI", "AdvancedTCA" ]
> 
> You can debug this on the remote system using an ansible checkout  
> there and ./hacking/test-module -m setup

Like this?  
hacking/test-module -m setup  
Traceback (most recent call last):  
&nbsp;&nbsp;File "hacking/test-module", line 148, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;main()  
&nbsp;&nbsp;File "hacking/test-module", line 138, in main  
&nbsp;&nbsp;&nbsp;&nbsp;(modfile, is\_new\_style) = boilerplate\_module(options.module\_path, options.module\_args)  
&nbsp;&nbsp;File "hacking/test-module", line 76, in boilerplate\_module  
&nbsp;&nbsp;&nbsp;&nbsp;module\_fh = open(modfile)  
IOError: [Errno 2] No such file or directory: 'setup'

Something does not look happy.

> If you put in a print to show the int(data) value, what do you get?

Huh? Who, when, what?

> Either way the module needs to try/except around this at least, such  
> that if it can't figure out the form factor nothing bad happens and  
> the setup module is still successful, and I'll file a bug about  
> this.

Ok.

/andreas

---

<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:** [August 2, 2012, 12:34pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/5 "2012-08-02T12:34:57Z")

</div>

> Like this?  
> hacking/test-module -m setup
> 
> Something does not look happy.

You'll need to give the full path, like -m ./library/setup

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 12:40pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/6 "2012-08-02T12:40:38Z")

</div>

> \>  
> \>  
> \> Like this?  
> \> hacking/test-module -m setup  
> \>  
> \>  
> \> Something does not look happy.
> 
> You'll need to give the full path, like -m ./library/setup

Something like this?

Return-Path: \<ansible-project+bncCL7RmIrIAhDz5-mABRoEm3lq9Q@googlegroups.com\>  
Received: from mail.snowmen.se ([unix socket])  
&nbsp;&nbsp;&nbsp;by mail.snowmen.se (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA;  
&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 14:35:02 +0200  
X-Sieve: CMU Sieve 2.2  
Received: from localhost (localhost.localdomain [127.0.0.1])  
&nbsp;&nbsp;by mail.snowmen.se (Postfix) with ESMTP id 266E2D40299  
&nbsp;&nbsp;for \<andreas.davour@snowmen.se\>; Thu, 2 Aug 2012 14:35:02 +0200 (CEST)  
X-Virus-Scanned: amavisd-new at snowmen.se  
X-Spam-Flag: NO  
X-Spam-Score: -2.599  
X-Spam-Level:  
X-Spam-Status: No, score=-2.599 tagged\_above=-100 required=6.2 tests=[BAYES\_00=-1.9, DKIM\_ADSP\_CUSTOM\_MED=0.001, DKIM\_SIGNED=0.1, DKIM\_VALID=-0.1, FREEMAIL\_FROM=0.001, RCVD\_IN\_DNSWL\_LOW=-0.7, SPF\_PASS=-0.001] autolearn=ham  
Authentication-Results: mail.snowmen.se (amavisd-new); dkim=pass header.i=@googlegroups.com  
Received: from mail.snowmen.se ([127.0.0.1])  
&nbsp;&nbsp;by localhost (mail.snowmen.se [127.0.0.1]) (amavisd-new, port 10024)  
&nbsp;&nbsp;with LMTP id Eom-LSbc26-z for \<andreas.davour@snowmen.se\>;  
&nbsp;&nbsp;Thu, 2 Aug 2012 14:35:01 +0200 (CEST)  
Received: from mail-gh0-f186.google.com (mail-gh0-f186.google.com [209.85.160.186])  
&nbsp;&nbsp;(using TLSv1 with cipher RC4-SHA (128/128 bits))  
&nbsp;&nbsp;(No client certificate requested)  
&nbsp;&nbsp;by mail.snowmen.se (Postfix) with ESMTP id 2D7E0D40298  
&nbsp;&nbsp;for \<andreas.davour@snowmen.se\>; Thu, 2 Aug 2012 14:35:01 +0200 (CEST)  
Received: by ghbf18 with SMTP id f18sf8354347ghb.23  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for \<andreas.davour@snowmen.se\>; Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:date:from:to:message-id:in-reply-to :references:subject:x-mailer:mime-version:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding:content-disposition; bh=xJdM4TOxl3KYCXuHWiWL07HQqfzG3sdfSsETy7FE95Y=; b=nT4wII+SYTQNAJ0F1UP3JH2XCo3E2C0EdcLm/pjod17a/0uomcL+MbL50ZYJj9dA8D skaes2hjP0VPqkQW1KooYjblzivTd86Zs1BmjJrkIR54HOrddRh5RqE3D8mntxHsu9lo qQD5jxIvJ8E1AyyjmnBu8YAj0Ld2nj1H6fySo=  
Received: by 10.236.170.7 with SMTP id o7mr4985372yhl.3.1343910899875;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
X-BeenThere: ansible-project@googlegroups.com  
Received: by 10.236.126.33 with SMTP id a21ls5240058yhi.3.gmail; Thu, 02 Aug  
2012 05:34:59 -0700 (PDT)  
Received: by 10.236.115.130 with SMTP id e2mr12359368yhh.25.1343910899314;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
Received: by 10.236.115.130 with SMTP id e2mr12359367yhh.25.1343910899303;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
Received: from mail-gg0-f169.google.com (mail-gg0-f169.google.com [209.85.161.169])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;by gmr-mx.google.com with ESMTPS id y43si1468509yhi.2.2012.08.02.05.34.59  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(version=TLSv1/SSLv3 cipher=OTHER);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
Received-SPF: pass (google.com: domain of michael.dehaan@gmail.com designates 209.85.161.169 as permitted sender) client-ip=209.85.161.169;  
Received: by ggm4 with SMTP id 4so9957086ggm.0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for \<ansible-project@googlegroups.com\>; Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
Received: by 10.236.193.105 with SMTP id j69mr20634895yhn.21.1343910899110;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:59 -0700 (PDT)  
Received: from fenrir.local (cpe-174-097-200-032.nc.res.rr.com. [174.97.200.32])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;by mx.google.com with ESMTPS id e16sm5396501ani.22.2012.08.02.05.34.57  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(version=TLSv1/SSLv3 cipher=OTHER);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thu, 02 Aug 2012 05:34:58 -0700 (PDT)

---

<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:** [August 2, 2012, 12:42pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/7 "2012-08-02T12:42:11Z")

</div>

Yep, … you've successfully run the setup module -- now just add some debug to figure out what it's returning for the form factor integer by printing it with print before the traceback is hit.

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 12:45pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/8 "2012-08-02T12:45:40Z")

</div>

I'm afraid you have to be quite specific. I know no python at all, and don't find it very readable either.

/andreas

---

<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:** [August 2, 2012, 12:46pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/9 "2012-08-02T12:46:45Z")

</div>

print int(data)

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 12:49pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/10 "2012-08-02T12:49:49Z")

</div>

def get\_dmi\_facts(self):  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (key,path) in LinuxHardware.DMI\_DICT.items():  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data = get\_file\_content(path)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if data is not None:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if key == 'form\_factor':  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print int(data)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.facts['form\_factor'] = LinuxHardware.FORM\_FACTOR[int(data)]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.facts[key] = data  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.facts[key] = 'NA'

Results in:

\* including generated source, if any, saving to: /root/.ansible\_module\_generated  
\* this will offset any line numbers in tracebacks/debuggers!

---

<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:** [August 2, 2012, 1:00pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/11 "2012-08-02T13:00:43Z")

</div>

Ok, thanks!

I'm going to add a check to make sure this error doesn't happen again and see if we can figure out what "28" should be.

If you want a fix in the meantime:

---

<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:** [August 2, 2012, 1:01pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/12 "2012-08-02T13:01:48Z")

</div>

Sorry for the spam, hit send early.

If you want a fix in the meantime, remove the print you added, and the line that says:

> self.facts['form\_factor'] = LinuxHardware.FORM\_FACTOR[int(data)]

and replace it with

self.facts['form\_factor'] = 'unknown'

This will keep it from exploding on your various machines.

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 1:24pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/13 "2012-08-02T13:24:57Z")

</div>

Excellent. Thanks Michael!

/andreas

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 1:39pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/14 "2012-08-02T13:39:36Z")

</div>

Sadly it seems like the fix only works on Fedora17. From my RHEL6.2 machine it says:

ansible sx1fe01.mt.gnuf.com -c ssh -m setup  
sx1fe01.mt.gnuf.com | FAILED =\> failed to parse: Traceback (most recent call last):  
&nbsp;&nbsp;File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 375, in \<module\>  
&nbsp;&nbsp;&nbsp;&nbsp;for (k, v) in ansible\_facts().items():  
&nbsp;&nbsp;File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 314, in ansible\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;get\_hardware\_facts(facts)  
&nbsp;&nbsp;File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 170, in get\_hardware\_facts  
&nbsp;&nbsp;&nbsp;&nbsp;self.facts['form\_factor'] = 'unknown'  
NameError: global name 'self' is not defined

I have python python-2.6.6-29.el6.x86\_64 on that, versus python-2.7.3-6.fc17.x86\_64 on the fedora machine. The ansible code is identical.

This I find curious. Isn't that code supposed to be run on the node I'm targetting?

/andreas

---

<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:** [August 2, 2012, 1:53pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/15 "2012-08-02T13:53:13Z")

</div>

Welcome to the world of python indentation being significant.

You can just do a new git pull or whatever to get the original version  
back, or maybe just delete the line. Either way.

Thanks for help in debugging!

---

<div class="post-metadata">

**Author:** ![Andreas\_Davour](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Andreas\_Davour](https://forum.ansible.com/u/Andreas_Davour)\
**Post date:** [August 2, 2012, 2:15pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/16 "2012-08-02T14:15:43Z")

</div>

Oh. That curiosity which I thought when I first hear of it that it  
would cause problem some day. Considering I actually know Fortran  
which used to have some ideas about indentation...

Then it's me being clueless again. What would I gain by deleting what line? Wont I just get the code with the index error if I git pull again?

/andreas

---

<div class="post-metadata">

**Author:** ![Stephen\_Fromm](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Stephen\_Fromm](https://forum.ansible.com/u/Stephen_Fromm)\
**Post date:** [August 2, 2012, 2:17pm UTC](https://forum.ansible.com/t/debugging-setup-problems/11750/17 "2012-08-02T14:17:15Z")

</div>

Andreas,

Can you run ‘dmidecode --type 3’ and send us the output? I can then update FORM\_FACTOR accordingly.

Thanks,  
sf
