Reputation: 370
In my playbook I want to run a delegated task on 4 load balancers. Can I just simply use delegate_to: loadbalancers_group
in my task? Will delegate_to
accept a group rather than a single host? I am not sure as the Ansible docs say:
delegate_to - Host to execute task instead of the target (inventory_hostname)
Upvotes: 3
Views: 5797
Reputation: 7
You could also use when: Example,
- file:
path: touched_file
state: touch
when: inventory_hostname in groups['loadbalancers_group']
Upvotes: -2
Reputation: 6158
No. The delegate_to
option needs to be a host, not a group.
What you can do is loop over the group, e.g.:
- file:
path: touched_file
state: touch
delegate_to: "{{ item }}"
loop: "{{ groups['loadbalancers_group'] }}"
Upvotes: 8