I am facing an issue where I need to specify hosts like this

   1. - hosts: "swarm-init-{{ env }}"


but trying to use that group value in hostvars stanza yields the below 
error. any suggestions?


   1. mtoken: "{{ hostvars[groups['swarm-init-{{ env }}'][0]]['manager'] | 
   replace('[u', '') | replace(']', '')}}"



{"failed": true, "msg": "'dict object' has no attribute 'swarm-init-{{ env 
}}'"}



On Saturday, August 6, 2016 at 10:15:56 AM UTC-5, Tony Owens wrote:
>
> I'm looking for some tips on the best way to store a variable persistently 
> across all hosts or multiple plays.
>
> I am attempting to create a docker swarm manager using something similar 
> to this:
>
>
>    1. - hosts: swarm-init
>    2. gather_facts: no
>    3. tasks:
>    4. - shell: docker swarm init
>    5. - shell: docker swarm join-token -q manager
>    6. register: manager
>    7. - shell: docker swarm join-token -q worker
>    8. register: worker
>
>
> I would run this play once and don't have that logic built yet but I have 
> not been able to find a method of storing {{ worker }} in a variable so 
> that I could join the swarm from another host in another play.  Any advice?
>

-- 
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/55242676-deeb-4698-8322-8b1fcc1ab92d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to