Perhaps the following will achieve your goal:

{% for source in lookup('together', containers, apps, wantlist=True) %}
container={{ source.0 }}
app={{ source.1 }}
{% endfor %}



On Wed, Dec 16, 2015 at 2:19 PM, Abel Makkonen Tesfaye <
[email protected]> wrote:

> I plan to use it in a template like so:
>
> {% for source in services %}
>
> container={{source.container}}
>
> app={{source.app}}
>
> {% endfor %}
>
>
> On Wed, Dec 16, 2015 at 12:03 PM, Matt Martz <[email protected]> wrote:
>
>> How do you plan on using this data.  Maybe there is a different way to
>> achieve your result, because it won't be easy or straight forward to get
>> what you want.
>>
>> Maybe with_together on a task could give you what you want instead:
>>
>> - debug: var=item
>>   with_together:
>>     - apps
>>     - containers
>>
>>
>>
>> On Wed, Dec 16, 2015 at 1:43 PM, <[email protected]> wrote:
>>
>>> I have 2 arrays
>>>
>>>
>>> "containers": [
>>>             "ContainerA",
>>>             "ContainerA",
>>>             "ContainerB",
>>>             "ContainerB"
>>>         ]
>>>
>>> "apps": [
>>>             "app2",
>>>             "app1",
>>>             "app2",
>>>             "app1"
>>>         ]
>>>
>>>
>>> I would like to merge them into an array of dictionaries like this ( I 
>>> assume with set_fact ):
>>>
>>> services:
>>> - { container: 'ContainerA', app: 'app2' }
>>> - { container: 'ContainerA', app: 'app1' }
>>> - { container: 'ContainerB', app: 'app2' }
>>> - { container: 'ContainerB', app: 'app1' }
>>>
>>>
>>> How can I do that?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/234b0651-72ac-4cdf-ba01-2283cdc5f425%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/234b0651-72ac-4cdf-ba01-2283cdc5f425%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAD8N0v8UvPkfG_1NZb7OLHKALcwLRXzhTrAY9LMPxyp%3DBHQvww%40mail.gmail.com
>> <https://groups.google.com/d/msgid/ansible-project/CAD8N0v8UvPkfG_1NZb7OLHKALcwLRXzhTrAY9LMPxyp%3DBHQvww%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAELhQndy1jN5KF32pHrLy4%3DBKhoGjsy0c_QmqMb11eJxim83cw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAELhQndy1jN5KF32pHrLy4%3DBKhoGjsy0c_QmqMb11eJxim83cw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-EpWJWtT4uNPMpfncaV%2BzT7H5M-WqQ8KDskDyPpCg1%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to