variables and delegate_to

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.

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’”

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?

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.