I'll reply to my own query; it can't be done. The first fact isn't 
available until the end of the task so the second fact cannot refer to it.

Me

On Tuesday, 12 July 2016 16:26:30 UTC+1, [email protected] wrote:
>
> Hi, I'm attempting to define a variable for use with set_fact and then 
> refer to it again when defining another variable. Is this 
> possible/supported? Eg.
>
> - name: Attempt to store host name in a temporary dictionary
>   set_fact:
>     host_name: "{{ host_prefix }}{{ (host_offset+item.0)|int }}-{{ 
> host_suffix }}"
>     name_map: "{{ name_map | default({}) | merge({ item.1.id: host_name 
> }) }}"
>   with_indexed_items: ec2.instances
>
> I can see that 'host_name' gets build correctly but the dictionary just 
> gets 'Undefined' :( If I remove the host_name definition above name_map, 
> how do I then nest all of that as the argument to the dictionary entry? It 
> looks darn ugly for starters but I can't even figure out the string 
> concatenation (with an integer throw in) inside the moustaches!
>
> Any guidance appreciated.
>
> Jim
>
> PS? The merge function is defined in filter_plugins/ - it's not part of 
> Ansible, though a standard addition.
>

-- 
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/601efc78-2d89-4ed5-8068-4bd13fea161a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to