【发布时间】:2015-10-29 03:17:10
【问题描述】:
我正在远程服务器 A 上生成一个存档文件。例如
/tmp/website.tar.gz
并希望将文件传输/复制并提取到远程服务器 B (/var/www)。
我如何在 Ansible 中做到这一点?
我创建归档文件的 Ansible 脚本:
- 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..
更新: 我可以使用rsync module 吗? .我正在尝试使用同步模块将存档文件复制到远程服务器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
它会产生错误:
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
我有服务器B的私钥,如何使用私钥远程访问服务器B?
【问题讨论】: