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.
问题:
回答1:
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.
回答2:
As of latest Ansible (v2.8), synchronize
is still in “preview” status:
This module is not guaranteed to have a backwards compatible interface. [preview]
I would use copy
when I don’t need the performance and functionality of synchronize
.
回答3:
Using ansible 2.4.2.0, this works flawlessly. I should probably not be using ansible from the CentOS repos. Too far behind the curve, no offense to CentOS.
- hosts: all
become: true
tasks:
- name: copy icinga2 2.7.2
synchronize:
src: /home/ansible/playbooks/files/icinga2.7
dest: /home/ansible
owner: yes