Currently ansible control machine: A
Currently ansible working host: B
Another host in inventory: C
I want to copy a file from C to B
At first, I tried rsync without ssh.
I create a rsync daemon in C and try to add this in the host B ansible tasks:
- name: copy file
command: rsync -az user@hostC.com::module/TheFile /home/userinhostB
When ansible run this task, it hangs without the prompt “password”
But I can input this same command in the host B terminal and got the prompt “password”, and the file copy success.
$ rsync -az user@hostC.com::module/TheFile /home/userinhostB
Then I tried to use rsync over ssh, like this
- name: copy file
command: rsync -az -rsh “ssh” userinhostC@hostC.com:DirToTheFile/TheFile /home/userinhostB
Still hanging.
Can anyone tell me where did I do this wrong?
Or what should I do to copy the file.