# combining with\_nested: + with\_together:

**URL:** <https://forum.ansible.com/t/combining-with-nested-with-together/17555>\
**Category:** Ansible Developer\
**Created:** [February 18, 2015, 5:43pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555 "2015-02-18T17:43:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [February 18, 2015, 5:43pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555/1 "2015-02-18T17:43:27Z")

</div>

Hi,

I've got 3 sets of data:

foo: [A, B, C, D, ...]  
bar: [1, 2]  
tra: [a, b]

foo should be combined with bar and tra in a nested loop, but bar and  
tra should loop together.

something like (not actually working):

- debug: msg="{{ item[0] }} {{ item[1][0] }} {{ item[1][1] }}  
&nbsp;&nbsp;with\_netsted:  
&nbsp;&nbsp;&nbsp;- foo  
&nbsp;&nbsp;&nbsp;- item  
&nbsp;&nbsp;&nbsp;with\_together:  
&nbsp;&nbsp;&nbsp;&nbsp;- bar  
&nbsp;&nbsp;&nbsp;&nbsp;- tra

Expected output:

A1a  
A2b  
B1a  
B2b  
C1a  
C2b  
...

How would I actually combine with\_nested: and with\_together?

thanks!  
Nusenu

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 18, 2015, 6:25pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555/2 "2015-02-18T18:25:15Z")

</div>

they are lookups, so you can do with\_\<lookup1\>: lookup('lookup2 ....)

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [February 18, 2015, 7:13pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555/3 "2015-02-18T19:13:30Z")

</div>

Brian Coca:

> they are lookups, so you can do with\_\<lookup1\>: lookup('lookup2  
> ....)

I'm sorry it is not entirely clear to me yet.

I didn't find something like this in the documentation at:  
[http://docs.ansible.com/playbooks\_lookups.html](http://docs.ansible.com/playbooks_lookups.html)  
[http://docs.ansible.com/playbooks\_loops.html](http://docs.ansible.com/playbooks_loops.html)

Could you point me to the documentation or provide an example?

thanks!  
Nusenu

---

<div class="post-metadata">

**Author:** ![Nusenu1](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nusenu1](https://forum.ansible.com/u/Nusenu1)\
**Post date:** [February 18, 2015, 9:53pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555/4 "2015-02-18T21:53:33Z")

</div>

Sorry, after reading [1] I figured I'm on the wrong list.  
To be honest I was surprised that the user documentation [2] links to a  
\*-devel list for further help:

"  
User Mailing List (points to [http://groups.google.com/group/ansible-devel](http://groups.google.com/group/ansible-devel))  
&nbsp;&nbsp;&nbsp;&nbsp;Have a question? Stop by the google group!  
"

I guess this should actually point to  
[http://groups.google.com/group/ansible-project](http://groups.google.com/group/ansible-project) , no?

Now I'm off to the ansible-project list - sorry for the off-topic post.

[1] [https://groups.google.com/d/msg/ansible-devel/lhvukkszKUA/S2DO7eqOvY0J](https://groups.google.com/d/msg/ansible-devel/lhvukkszKUA/S2DO7eqOvY0J)  
[2] [http://docs.ansible.com/playbooks\_loops.html](http://docs.ansible.com/playbooks_loops.html) (this is just an  
example almost any documentation page has that link)

---

<div class="post-metadata">

**Author:** ![Greg\_DeKoenigsberg1](https://avatars.discourse-cdn.com/v4/letter/g/838e76/32.png) [@Greg\_DeKoenigsberg1](https://forum.ansible.com/u/Greg_DeKoenigsberg1)\
**Post date:** [February 18, 2015, 10:02pm UTC](https://forum.ansible.com/t/combining-with-nested-with-together/17555/5 "2015-02-18T22:02:59Z")

</div>

Nice catch. Looks like there's something busted in the template there -- thanks!

--g
