我需要将文件从机器A复制到机器B,而运行我所有可完成任务的控制机器是机器C(本地机器)
我尝试了以下方法:
在Ansible的Shell模块中使用scp命令
hosts: machine2
user: user2
tasks:
- name: Copy file from machine1 to machine2
shell: scp user1@machine1:/path-of-file/file1 /home/user2/file1
这种方法永无止境。
使用提取和复制模块
hosts: machine1
user: user1
tasks:
- name: copy file from machine1 to local
fetch: src=/path-of-file/file1 dest=/path-of-file/file1
hosts: machine2
user: user2
tasks:
- name: copy file from local to machine2
copy: src=/path-of-file/file1 dest=/path-of-file/file1
这种方法给我抛出如下错误:
error while accessing the file /Users/<myusername>/.ansible/cp/ansible-ssh-machine2-22-<myusername>, error was: [Errno 102] Operation not supported on socket: u'/Users/<myusername>/.ansible/cp/ansible-ssh-machine2-22-<myusername>'
任何的意见都将会有帮助。