且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将文件保存在本地计算机中,该文件是在远程计算机中生成的?

更新时间:2023-08-21 09:32:46

您可以使用 模块可将文件从本地复制到远程或从远程复制到本地主机.例如

You can use the synchronize module to copy files from local to remote or from remote to local host. For example

- name: 'Copy run.sh to remote machine'
  synchronize:
    mode: push
    src: top.sh
    dest: /home/username

- name: Execute the script
  command: sh /home/username/top.sh

- name: 'Copy system.txt to local machine'
  synchronize:
    mode: pull
    src: /home/username/system.txt
    dest: .

注意:要使synchronize模块正常工作,您需要在主机上安装rsync.

Note: for the synchronize module to work you will need to have rsync installed on the hosts.