variables and delegate_to

274 views
Skip to first unread message

Nico K.

unread,
Sep 10, 2014, 9:24:09 AM9/10/14
to ansible...@googlegroups.com
Hi,

Quick question, I'm defining a group variable to be 'delegate_group: test' or "delegate_group: live' depending on the --limit clause used.
The variable is being properly defined (as can be seen with debug: msg=""), however when I pass that variable to delegate_to: "{{ delegate_group }}" it resolves to the value I filled in but it doesn't see that this varialbe is actually a group defined in 'hosts'.
Is this behavior to be expected? If so, how does one approach a scenario like this?

Thanks,
Nico.

Michael DeHaan

unread,
Sep 10, 2014, 9:27:24 AM9/10/14
to ansible...@googlegroups.com
delegate_to does not take a list, but it takes a host name.  You can use it with "with_items" and so on.

I didn't parse the part about "a group defined in 'hosts'"



--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f62e461c-038d-4305-b254-76a406d29f62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nico K.

unread,
Sep 10, 2014, 9:36:40 AM9/10/14
to ansible...@googlegroups.com
In my hosts file I have a group defined called 'live' for example.

[live]
myhost1.example.com
myhost2.example.com

I want to delegate_to: live

Is that possible?



Nico K.

unread,
Sep 10, 2014, 4:20:43 PM9/10/14
to ansible...@googlegroups.com
For those wondering, yes it's possible as per Michael's pointer you can use with_items, so one can do:

delegate_to: '{{ item }}'
with_items: groups('groupname')

where groupname can also be a (custom) fact or variable.


Op woensdag 10 september 2014 15:36:40 UTC+2 schreef Nico K.:
Reply all
Reply to author
Forward
0 new messages