I have a playbook that looks like this:
----8<-- playbook --8<----
I have a playbook that looks like this:
----8<-- playbook --8<----
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
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:
# 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.
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:# 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):
File "hacking/test-module", line 148, in <module>
main()
File "hacking/test-module", line 138, in main
(modfile, is_new_style) = boilerplate_module(options.module_path, options.module_args)
File "hacking/test-module", line 76, in boilerplate_module
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
Like this?
hacking/test-module -m setupSomething does not look happy.
You'll need to give the full path, like -m ./library/setup
>
>
> 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])
by mail.snowmen.se (Cyrus v2.2.12-Invoca-RPM-2.2.12-8.1.RHEL4) with LMTPA;
Thu, 02 Aug 2012 14:35:02 +0200
X-Sieve: CMU Sieve 2.2
Received: from localhost (localhost.localdomain [127.0.0.1])
by mail.snowmen.se (Postfix) with ESMTP id 266E2D40299
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])
by localhost (mail.snowmen.se [127.0.0.1]) (amavisd-new, port 10024)
with LMTP id Eom-LSbc26-z for <andreas.davour@snowmen.se>;
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])
(using TLSv1 with cipher RC4-SHA (128/128 bits))
(No client certificate requested)
by mail.snowmen.se (Postfix) with ESMTP id 2D7E0D40298
for <andreas.davour@snowmen.se>; Thu, 2 Aug 2012 14:35:01 +0200 (CEST)
Received: by ghbf18 with SMTP id f18sf8354347ghb.23
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;
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;
Thu, 02 Aug 2012 05:34:59 -0700 (PDT)
Received: by 10.236.115.130 with SMTP id e2mr12359367yhh.25.1343910899303;
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])
by gmr-mx.google.com with ESMTPS id y43si1468509yhi.2.2012.08.02.05.34.59
(version=TLSv1/SSLv3 cipher=OTHER);
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
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;
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])
by mx.google.com with ESMTPS id e16sm5396501ani.22.2012.08.02.05.34.57
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 02 Aug 2012 05:34:58 -0700 (PDT)
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.
I'm afraid you have to be quite specific. I know no python at all, and don't find it very readable either.
/andreas
print int(data)
def get_dmi_facts(self):
for (key,path) in LinuxHardware.DMI_DICT.items():
data = get_file_content(path)
if data is not None:
if key == 'form_factor':
print int(data)
self.facts['form_factor'] = LinuxHardware.FORM_FACTOR[int(data)]
else:
self.facts[key] = data
else:
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!
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:
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.
Excellent. Thanks Michael!
/andreas
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):
File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 375, in <module>
for (k, v) in ansible_facts().items():
File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 314, in ansible_facts
get_hardware_facts(facts)
File "/var/tmp/ansible-1343914510.53-262311802435614/setup", line 170, in get_hardware_facts
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
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!
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
Andreas,
Can you run ‘dmidecode --type 3’ and send us the output? I can then update FORM_FACTOR accordingly.
Thanks,
sf