问题原文
原帖链接 · maayke · CC BY-SA 3.0
I would like to copy files from remote directory to local directory with Ansible but fetch module allows me to copy only one file. I have many servers from which I need files (same directory each server) and I don't now how to do this with Ansible.
Any ideas?
社区高分解答
原帖链接 · Duncan Lock · CC BY-SA 4.0
You should use the synchronise module to do this. This uses the awesome power of rsync. It will copy file & directory structures of any depth, is bulletproof and highly efficient - only copying the actual bytes that have changed:
- name: Fetch stuff from the remote and save to local
synchronize: src={{ item }} dest=/tmp/ mode=pull
with_items:
- "folder/one"
- "folder/two"
The key is the mode parameter:
Specify the direction of the synchronization. In push mode the localhost or delegate is the source; In pull mode the remote host in context is the source.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
