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)
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'] }}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With