Apologies, the empty list outcomes are when I have left a vhosts : [] 
knocking about somewhere. The error is in fact the same in all cases:

"recursive loop detected in template string"

On Friday, May 16, 2014 5:41:25 PM UTC+1, Martin Devlin wrote:
>
> OK, thanks for persevering with this! So in group_vars I have lists like 
> this:
>
> ext_vhosts:
>
>   - name         : site1
>     hostname     : "{{ site1_hostname }}"
>     ipaddress    : "{{ site1_ip_address }}"
>     ssl_cn       : "{{ site1_ssl_hostname }}"
>     ssl_key      : site1.key
>     ssl_crt      : site1.crt
>     ssl_pem      : site1.pem
>     apache_dir   : site1
>     conf_file    : site1.conf
>
>   - name         : site2
>     hostname     : "{{ site2_hostname }}"
>     ipaddress    : "{{ site2_ip_address }}"
>     ssl_cn       : "{{ site2_ssl_hostname }}"
>     ssl_key      : site2.key
>     ssl_crt      : site2.crt
>     ssl_pem      : site2.pem
>     apache_dir   : site2d
>     conf_file    : site2d.conf
>  
> int_vhosts:
>
>   - name         : site3
>     hostname     : "{{ site3_hostname }}"
>     ipaddress    : "{{ site3_ip_address }}"
>     ssl_cn       : "{{ site3_ssl_hostname }}"
>     ssl_key      : site3.key
>     ssl_crt      : site3.crt
>     ssl_pem      : site3.pem
>     apache_dir   : site3
>     conf_file    : site3.conf
>
>   - name         : site4
>     hostname     : "{{ site4_hostname }}"
>     ipaddress    : "{{ site4_ip_address }}"
>     ssl_cn       : "{{ site4_ssl_hostname }}"
>     ssl_key      : site4.key
>     ssl_crt      : site4.crt
>     ssl_pem      : site4.pem
>     apache_dir   : site4d
>     conf_file    : site4d.conf
>  
> etc...
>
> I can use ext_vhosts and int_vhosts just fine, I just can't join them 
> together.
>
> The test case is as simple as:
>
> debug : msg="{{ vhosts }}"
>
> So this in the <role>/defaults/main.yml:
>
> vhosts : []
> vhosts : "{{ vhosts|union(ext_vhosts)|union(int_vhosts) }}
>
> Yields an empty list
>
> vhosts        : "{{ vhosts|union(ext_vhosts) }}"
> vhosts        : "{{ vhosts|union(int_vhosts) }}""
>
> Yields an empty list
>
> In both cases debug : msg="{{ ext_vhosts }}" shows the expected values.
>
> If I put the same structures in vars/main.yml I get "an unexpected type 
> error occured. Error was unhashable type: 'dict'"
>
> If I put the union statements in the respective group_vars files I get 
> "recursive loop detected in template string {{vhosts|union(ext_vhosts)}}"
>
> I hope it's just a case of putting them in a different file or that 
> there's just a bit of missing syntax somewhere.
>
>>
>> On Thu, May 15, 2014 at 5:56 PM, Martin Devlin <[email protected]> wrote:
>>
>>> I tried this but couldn't get this to work in variables files. I think 
>>> union is only available in templates.
>>>
>>> Serge van Ginderachter's suggestion is the only one I've tried that 
>>> meets my requirement and it's not ideal as he admits himself.
>>>
>>> I thought stacking variables like this would make sense; I can see quite 
>>> a few uses for it in a hierarchical inventory structure, but the fact that 
>>> no one has requested it as a feature suggests to me I'm approaching 
>>> group_vars in the wrong way; I'm coming to it from using hiera in puppet.
>>>
>>> --
>>> 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/099a7d14-1d02-4686-b1db-f2fedb46459a%40googlegroups.com
>>> .
>>> 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/8bb921dc-b069-4d56-83cc-ec4ab4b2e022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to