Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible Copy vs Synchronize

Tags:

ansible

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.

like image 982
Alex Ethier Avatar asked Sep 08 '15 22:09

Alex Ethier


2 Answers

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.

like image 178
Mxx Avatar answered Nov 17 '22 07:11

Mxx


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!)

like image 20
Franklin Yu Avatar answered Nov 17 '22 08:11

Franklin Yu