I'm generating an archived file on remote server A. e.g.
/tmp/website.tar.gz
and want to transfer/copy and extract the file to the remote server B (/var/www).
How do I do that in Ansible?
My Ansible script to create archived file:
- name: archive files
shell: tar -zczf /tmp/website.tar.gz .
args:
chdir: "{{ source_dir }}"
tags: release
- name: copy archived file to another remote server and unpack to directory /var/www. unresolved..
Update: Can I use the rsync module? . I'm trying to use the synchronize module to copy the archived file to the remote server B:
- name: copy archived file to another remote server and unpack to directory /var/www
synchronize:
src: /tmp/website.tar.gz
dest: /var/www
rsync_opts:
- "--rsh=ssh -i /home/agan/key/privatekey"
delegate_to: remote_server_b
tags: test
it produces an error:
fatal: [remote_server_b] => SSH Error: Permission denied (publickey).
while connecting to xxx.xxx.xxx.129:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
FATAL: all hosts have already failed -- aborting
I have a private key for server B, how to remotely access the server B using private key?