I am trying to copy the files from Server A to Server B with Ansible running in Server C.
I have tried using Ansible Synchronize Module:
Exchanged SSH id_rsa.pub keys between the servers. Was able to ssh between the servers without asking password.
When running playbook it was able to gather_facts but throwing error during task execution. If seen in verbose output it is trying yo connect to different ip’s rather than the ips mentioned in the host file.
If you can observe the verbose output rather than connecting to 192.168.1.2 it is trying to connect to 198.105.254.228 , 198.105.244.228. These ip’s are not mentioned in the host file nor the server ip address. Why is it connecting to those addresses.
Your hosts file appears to be using groups for ServerA and ServerB.
delegate_to doesn't actually know about groups so delegate_to is not
finding an ansible host with that name and then it's consulting dns as
a fallback. there are several ways to achieve what you want, though.
* In your example hosts file, it looks like you can define a host
rather than a group for ServerA and ServerB.
* If you do have multple Servers to process, you can use a loop:
- name: Transferring file from ServerA to ServerB
synchronize:
src: /home/ubuntu/Dockerfile
dest: /home/ubuntu
delegate_to: '{{ item }}'
with_inventory_hostnames: ServerA