# get item from nested loop item

**URL:** <https://forum.ansible.com/t/get-item-from-nested-loop-item/38561>\
**Category:** Ansible Project\
**Created:** [November 1, 2023, 10:37am UTC](https://forum.ansible.com/t/get-item-from-nested-loop-item/38561 "2023-11-01T10:37:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaishnave\_M](https://avatars.discourse-cdn.com/v4/letter/v/50afbb/32.png) [@Vaishnave\_M](https://forum.ansible.com/u/Vaishnave_M)\
**Post date:** [November 1, 2023, 10:37am UTC](https://forum.ansible.com/t/get-item-from-nested-loop-item/38561/1 "2023-11-01T10:37:02Z")

</div>

Hi,

I have list of items in configuration files as variable

hostenv:

- env: test  
Serverconf:  
Resource:
- mem:  
Interface:
- { name: eth0, address: 10.0.10.2}
- {eth1: …}

Now, I would like to fetch and print the values from interface {{ item.address }}

I tried to loop multiple usecase, but failed with object undefined error

Playbook:  
task:

- debug:  
msg: {{ item.address }}  
loop: {{ hostenv.Serverconf.Interface }}  
loop\_var: item

Thanks

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [November 1, 2023, 2:13pm UTC](https://forum.ansible.com/t/get-item-from-nested-loop-item/38561/2 "2023-11-01T14:13:28Z")

</div>

It’s hard to tell from this platform’s poor support of indentation, but it appears “hostenv” is a list. Try  
loop: “{{ hostenv[0].Serverconf.Interface }}”
