I have the following task inside an Ansible playbook. I simply want to copy 4 dirs from a remote location (server2) to the same path on the target node (server1)
When running the playbook (using tower) when it reaches this task it just hangs, there is no debug information even on the highest verbosity it only shows tower connecting then nothing further
- name: "Copy files from {{ server2 }}"
become: "{{ appuser }}"
shell: "scp -pr {{ appuser }}@{{ server2 }}:{{ item }} {{ item }}"
with_items:
- /opt/dir1
- /opt/some/otherdir
- /opt/directory
- /opt/another/folder
to answer expected questions:
- SSH keys for that user have already been setup on both server1 and server2 and tested and stricthostkey checking is set to no globally
- Running the scp command manually as the appuser on server1 replacing the variables works perfectly fine
- Using copy command is not an option as the files are not on the ansible server/tower, only the remote server2, and Synchronize module cannot be used as rsync is not permitted to be installed
- even when only using 1 item in with_items the issue persists
- if you dont use variables and just hardcode a regular scp command into the playbook for 1 dir it works fine ( shell: "scp -pr {username@10.10.10.2:/path/to/dir/path/to/dir"
- I have tried using "" on the with_items list didn't make a difference
Additional Notes
only server1 is connected to ansible, server2 is not, it is truely remote, consider it a 3rd party.