Thanks for the pointer Michael, here's what I ended up doing.

{
    "combined": [ "{{first_list | union(second_list) | join('", "')}}"]
}

On Thursday, 20 February 2014 10:27:38 UTC-8, Michael DeHaan wrote:
>
> Here's some documentation on set theory filters that may help:
>
> http://docs.ansible.com/playbooks_variables.html#id22
>
>
>
>
> On Thu, Feb 20, 2014 at 1:25 PM, Stephen Gargan 
> <[email protected]<javascript:>
> > wrote:
>
>>
>> I'd like to be able to do the following, hopefully someone can point me 
>> to a simple way to do it.
>>
>> I have two lists, one contains vars for all hosts another vars for a 
>> specific host. I'd like to join them into a single list that can be 
>> iterated over in a template. I reuse the template so would rather it did 
>> not know about two separate lists.
>>
>> generic_vars: [ 'a', 'b', 'c' ]
>> specific_vars: [ 'd', 'e' ]
>>
>> somehow I'd like to combine these into an all_vars variable, so that in 
>> the template I can do the following.
>>
>> mytemplate.json
>>
>> {
>>   "vars": [
>> {% for v in all_vars %}
>>         "{{v}}"{% if not loop.last %},{% endif %}
>> {% endfor %}
>>     ]
>> }
>>
>> This is a patten that arises a lot for me so I'm probably going to write 
>> a module to do it. But I thought I'd check to see if there was a simple 
>> standard way of doing so before heading down that path.
>>
>> Is this something that can be easily done?
>>
>> thanks,
>>
>> Steve.
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to