# Complex loops?

**URL:** <https://forum.ansible.com/t/complex-loops/19108>\
**Category:** Ansible Project\
**Created:** [August 25, 2015, 12:00pm UTC](https://forum.ansible.com/t/complex-loops/19108 "2015-08-25T12:00:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico\_K](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@Nico\_K](https://forum.ansible.com/u/Nico_K)\
**Post date:** [August 25, 2015, 12:00pm UTC](https://forum.ansible.com/t/complex-loops/19108/1 "2015-08-25T12:00:20Z")

</div>

Hi,

Given the following structure:

roles/bugzilla/vars/main.yml:

bugzilla:  
vhost:  
name: x  
stuff: c

roles/subversion/vars/main.yml:

subversion:  
vhost:  
name: y  
stuff: d

I’m trying to do the following

playbook.yml:

- name: x  
…  
roles:
- { role: apache, vhosts: [‘subversion’, ‘bugzilla’] }

roles/apache/tasks/main.yml:

- name: render vhosts  
template:  
src: {{ item[‘vhost’][‘name’] }}.conf  
…  
with\_items:
- vhosts

I would expect that the with\_items loops evaluated ‘vhosts’ to subversion and bugzilla and in term give me access to the underlying structure of those variables, thus bugzilla.vhost.name etc. however I can’t seem to get this to work.  
What am I doing wrong here? Or is this simply not supported?

Thanks,  
Nico
