I appear to be having a problem when trying to pass a list of hosts to delegate_to, within a role.
(Simplified examples to demonstrate the behavior I am seeing, using freshly cloned version from Github)
This works as expected:
site.yml---
- name: test delegation
hosts: delegator.example.com
sudo: yes
tasks:
- name: delegate a task
command: /bin/date
delegate_to: "{{ item }}"
with_items:
- delegate1.example.com
- delegate2.example.com
This does not:
site.yml- name: test delegation
hosts: delegator.example.com
sudo: yes
roles:
- delegator
roles/delegator/tasks/main.yml---
- name: delegate a task
command: /bin/date
delegate_to: "{{ item }}"
with_items:
- delegate1.example.com
- delegate2.example.com
failing with:
fatal: [delegator.example.com] => SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh
Ideally, the list will come from somewhere else in actual use, but again, keeping it simple to demonstrate the problem.
Is this the expected behavior for delegation within a role, or am I doing it wrong, or is Ansible doing it wrong?