fetch模块:
copy模块:
1、从远程主机获取文件:ansible all -m fetch -a "src=/root/test.sh dest=/root/test"

image.png
2、从本地主机传到远程:ansible all -m copy -a "src=/root/test.txt dest=/root"

image.png
3、远程复制或者本地上传,加上force=yes,则会覆盖掉原来的文件,加上backup=yes,在覆盖的时候会把原来的文件做一个备份: ansible all -m copy -a "src=/root/test.txt dest=/root force=yes backup=yes"

image.png
4、复制的时候可以带参数:owner,group,mode