以並行的方式同時 SCP 大量的文件到多台機器. 命令如下:
ansible atlanta -m copy -a "src=/etc/hosts dest=/tmp/hosts"
使用 file 模塊可以做到修改文件的屬主和權限:
ansible webservers -m file -a "dest=/srv/foo/a.txt mode=600"
ansible webservers -m file -a "dest=/srv/foo/b.txt mode=600 owner=mdehaan group=mdehaan"
使用 file 模塊也可以創建目錄,與執行 mkdir -p 效果類似:
ansible webservers -m file -a "dest=/path/to/c mode=755 owner=mdehaan group=mdehaan state=directory"
刪除目錄(遞歸的刪除)和刪除文件:
ansible webservers -m file -a "dest=/path/to/c state=absent"