Ansible Copy vs Synchronize

2019-06-15 13:07发布

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.

标签: ansible
3条回答
放荡不羁爱自由
2楼-- · 2019-06-15 13:31

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
查看更多
Ridiculous、
3楼-- · 2019-06-15 13:38

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.

查看更多
贼婆χ
4楼-- · 2019-06-15 13:45

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.

查看更多
登录 后发表回答