我需要将文件格式机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
Run Code Online (Sandbox Code Playgroud)
这种方法一直持续下去.
使用获取和复制模块
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
Run Code Online (Sandbox Code Playgroud)
这种方法给我一个错误如下:
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>'
Run Code Online (Sandbox Code Playgroud)
任何的意见都将会有帮助.
ansible ×1