I'm attempting to use ansible synchronize to copy files between two remotes.
My playbook looks like:
- hosts: newserver
tasks:
- name: Copy images from old to new
synchronize:
src: /var/www/production/
dest: /var/www/production/
delegate_to: oldserver
Where newserver
and oldserver
are defined in my inventory file. If I replace oldserver
with the full hostname the delegate_to works. Otherwise it complains about unreachable. oldserver
works fine in other places in other playbooks.
Doesn't delegate_to use the inventory?
The error I get is:
TASK [Copy images from old to new] *************************************************
fatal: [thr.cs.unc.edu]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ", "unreachable": true}
newserver
is reachable from oldserver
. As I said above, if I change oldserver
to gbserver3.cs.unc.edu
in the delegate_to it works.
My hosts file looks like this:
[newserver]
thr.cs.unc.edu
[oldserver]
gbserver3.cs.unc.edu