文件传送
## 传送文件
ansible all -m copy -a "src=/tmp/aa.txt dest=/tmp/aa.txt" -k
##
文件夹传送
- hosts: all
tasks:
- name: Copy project files and delete extra files
copy:
src: /path/to/your/project/
dest: /opt/myapp
remote_src: yes
state: sync
ansibe rsync 传送
- hosts: all
tasks:
- name: Synchronize project files
synchronize:
src: /path/to/your/project/
dest: /opt/myapp # 确保目标主机上存在但源文件夹中不存在的文件会被删除
delete: yes
recursive: yes
checksum: yes
owner: yes
group: yes