# IndexError in plugins/lookup/subelements.py after upgrade from 1.9 to 2.0

**URL:** <https://forum.ansible.com/t/indexerror-in-plugins-lookup-subelements-py-after-upgrade-from-1-9-to-2-0/20983>\
**Category:** Ansible Project\
**Created:** [March 24, 2016, 4:34pm UTC](https://forum.ansible.com/t/indexerror-in-plugins-lookup-subelements-py-after-upgrade-from-1-9-to-2-0/20983 "2016-03-24T16:34:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JK\_Laiho](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@JK\_Laiho](https://forum.ansible.com/u/JK_Laiho)\
**Post date:** [March 24, 2016, 4:34pm UTC](https://forum.ansible.com/t/indexerror-in-plugins-lookup-subelements-py-after-upgrade-from-1-9-to-2-0/20983/1 "2016-03-24T16:34:05Z")

</div>

Upgrading from 1.9.5 to 2.0.1.0 without changing the playbook, a task fails that used to work.

The error:

[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future this will be a fatal error… This feature will be removed in a

future release. Deprecation warnings can be disabled by setting deprecation\_warnings=False in ansible.cfg.

An exception occurred during task execution. The full traceback is:

Traceback (most recent call last):

File “/usr/local/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 89, in run

items = self.\_get\_loop\_items()

File “/usr/local/lib/python2.7/site-packages/ansible/executor/task\_executor.py”, line 189, in \_get\_loop\_items

items = self.\_shared\_loader\_obj.lookup\_loader.get(self.\_task.loop, loader=self.\_loader, templar=templar).run(terms=loop\_terms, variables=self.\_job\_vars)

File “/usr/local/lib/python2.7/site-packages/ansible/plugins/lookup/subelements.py”, line 37, in run

terms[0] = listify\_lookup\_plugin\_terms(terms[0], templar=self.\_templar, loader=self.\_loader)

IndexError: list index out of range

fatal: [somehostname]: FAILED! =\> {“failed”: true, “msg”: “Unexpected failure during module execution.”, “stdout”: “”}

to retry, use: --limit @deploy.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

somehostname : ok=4 changed=1 unreachable=0 failed=1

The task:

- name: copy apt key files from all roles to /tmp  
become: no  
copy: src=“{{ item.1.path }}/{{ item.1.filename }}” dest=“/tmp/{{ item.1.filename }}”  
when: “‘{{ item.0.role }}’ in {{ role\_names }} and ‘{{ item.1.pub }}’ not in ansible\_local.installed\_apt\_keys.key\_list”  
with\_subelements:
- ‘{{ apt\_keys\_by\_role }}’
- ‘{{ keyfiles }}’

The relevant variables:

apt\_keys\_by\_role:

- role: common  
keyfiles:
- path: “{{ inventory\_dir }}/roles/common/files/apt\_keys”  
filename: linode.gpg  
pub: 325A043E
- role: dev  
keyfiles:
- path: “{{ inventory\_dir }}/roles/dev/files/apt\_keys”  
filename: nodesource.gpg.key  
pub: 68576280

Ideas about what I need to do to fix this for 2.0?

Bonus points: how do you use pdb with Ansible’s Python modules? I tried sticking import pdb; pdb.set\_trace() before the line that produces the IndexError in /usr/local/lib/python2.7/site-packages/ansible/plugins/lookup/subelements.py, but that turns the error into a BdbQuit; the (pdb) prompt is printed but it insta-quits and keeps on going with the task.
