What is the difference between `copy`, `synchronize` and `fetch`?
IntermediateConceptAd-hoc Commands, Modules and Idempotency
Answer
copy sends files from the control node to the target (or copies on the target with remote_src: true), and is fine for small files. synchronize wraps rsync (from ansible.posix) for large trees and deltas, and requires rsync on both ends. fetch goes the other way: it pulls files from targets to the control node.
- ansible.posix.synchronize:
src: build/
dest: /var/www/app/
delete: true
- ansible.builtin.fetch:
src: /var/log/app.log
dest: logs/
fetch stores files under dest/<hostname>/path by default so hosts do not overwrite each other.
More on Ad-hoc Commands, Modules and Idempotency
What is an ad-hoc command and what is its syntax?BeginnerWhat does `ansible all -m ping` actually test?BeginnerGive practical use cases for ad-hoc commands.IntermediateWhat is the difference between the `command` and `shell` modules?BeginnerCompare `raw`, `command`, `shell` and `script`.IntermediateWhy prefer a dedicated module over `shell`/`command`?Beginner