# with\_items clause with ios config module is not working

**URL:** <https://forum.ansible.com/t/with-items-clause-with-ios-config-module-is-not-working/26968>\
**Category:** Ansible Project\
**Created:** [March 12, 2018, 4:01pm UTC](https://forum.ansible.com/t/with-items-clause-with-ios-config-module-is-not-working/26968 "2018-03-12T16:01:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishlesh\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vishlesh\_Patel](https://forum.ansible.com/u/Vishlesh_Patel)\
**Post date:** [March 12, 2018, 4:01pm UTC](https://forum.ansible.com/t/with-items-clause-with-ios-config-module-is-not-working/26968/1 "2018-03-12T16:01:40Z")

</div>

vars:  
hubs: “{{groups[‘Hubs’]}}”  
connection: local

tasks:

- name: debug tasks  
debug:  
msg: “{{hostvars[item].tunnel\_address}}”  
with\_items: “{{ hubs }}”

- name: test ios config  
ios\_config:  
parents: interface Tunnel1  
lines:

- description {{ hostvars[item].tunnel\_address }}  
with\_items: “{{ hubs }}”

Output of the playbook:  
TASK [debug tasks] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [Spoke1] =\> (item=Hub1) =\> { “changed”: false, “item”: “Hub1”, “msg”: “1.1.1.1” } ok: [Spoke1] =\> (item=Hub2) =\> { “changed”: false, “item”: “Hub2”, “msg”: “1.1.1.2” } ok: [Spoke2] =\> (item=Hub1) =\> { “changed”: false, “item”: “Hub1”, “msg”: “1.1.1.1” } ok: [Spoke2] =\> (item=Hub2) =\> { “changed”: false, “item”: “Hub2”, “msg”: “1.1.1.2” }

TASK [test ios config] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [Spoke1]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to have been in ‘/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.yml’:line 28, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test ios config\n ^ here\n\nexception type: \<class ‘ansible.errors.AnsibleUndefinedVariable’\>\nexception: ‘item’ is undefined”}  
fatal: [Spoke2]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to have been in ‘/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.yml’:line 28, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: test ios config\n ^ here\n\nexception type: \<class ‘ansible.errors.AnsibleUndefinedVariable’\>\nexception: ‘item’ is undefined”}  
to retry, use: --limit @/Users/vishlpa4/central-orchestration/cso-transit-vpc-poc/configureSpokes.retry

Any idea why this is failing ? Am I not supposed to use item in ios\_config module

---

<div class="post-metadata">

**Author:** ![Vishlesh\_Patel](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vishlesh\_Patel](https://forum.ansible.com/u/Vishlesh_Patel)\
**Post date:** [March 12, 2018, 4:38pm UTC](https://forum.ansible.com/t/with-items-clause-with-ios-config-module-is-not-working/26968/2 "2018-03-12T16:38:40Z")

</div>

Found the issue.

with\_items is part of task, not part of ios\_config. Hence, it should align and have same indent as ios\_config.

[https://stackoverflow.com/questions/35270024/ansible-item-is-undefined](https://stackoverflow.com/questions/35270024/ansible-item-is-undefined)
