What are the pros and cons to using Ansible Synchronize vs Copy modules. As far as I can tell synchronize has all the functionality that copy does but may be much faster so I'm considering changing everything to use synchronize. The only downside of synchronize is that rsync is required, which seems fairly ubiquitous in the Linux environment.
The differences are pretty similar to traditional rsync
vs scp
. Rsync has more features and is often faster, however it's a little bit trickier to setup and has more knobs to turn.
Additionally, https://docs.ansible.com/ansible/copy_module.html states:
The “copy” module recursively copy facility does not scale to lots (>hundreds) of files. For alternative, see synchronize module, which is a wrapper around rsync.
As of Ansible v2.8, synchronize
is still in “preview” status:
This module is not guaranteed to have a backwards compatible interface. [preview]
In Ansible v2.10, the copy
module is moved to the Builtin Collection, which is officially maintained by the core team (i.e. Red Hat), and distributed with ansible-base
(a.k.a. ansible-core
). In contrast, synchronize
is moved to the POSIX Collection maintained by community.
I would use copy
when I don’t need the performance and functionality of synchronize
. I suggest starting with copy
, and move to synchronize
only when this is the bottleneck. (Verify this with benchmark!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With