我需要复制文件形式的机器 A 到机器 B,而我的控制机器从那里我运行所有可能的任务是机器 C (本地机器)
I have tried the following:
在可视化的 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>'
任何建议都会有帮助。