1.

How does Ansible synchronize module works?

Answer»

Ansible synchronize is a module similar to rsync in Linux machines which we can use in playbooks. The features are similar to rsync such as archive, compress, delete, etc but there are few limitations also such as

  • Rsync must be installed on both source and target systems
  • Need to specify delegate_to to change the source from localhost to some other port
  • Need to handle user permission as files are ACCESSIBLE as per remote user.
  • We should always give the full PATH of the destination host location in CASE we use sudo otherwise files will be copied to the remote user home directory.
  • Linux rsync limitations related to hard LINKS are also applied here.
  • It forces -delay-updates to AVOID the broken state in case of connection failure

An example of synchronize module is

---- hosts: host-remote tasks:- name: sync from sync_foldersynchronize:src: /var/tmp/sync_folder dest: /var/tmp/

Here we are transferring files of /var/tmp/sync_folder folder to remote machine’s /var/tmp folder



Discussion

No Comment Found