Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till November 30th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

Ansible Synchronize | All About

by | Oct 9, 2022

Ansible Synchronize is a wrapper around rsync that allows us to perform common tasks easily and smoothly via playbook. With our Server Management Sevices, Bobcares provides solutions for your server-related issues.

What Is Ansible Synchronize?

Ansible Synchronize is a module that performs some of the common tasks performed on Linux machines by rsync. We can still use the command and shell modules to call rsync, but this requires some additional host facts and parameters to work properly. The working of Ansible synchronize is similar to that of rsync in many ways.

 

ansible synchronize

We have to keep certain things in mind while using Ansible Synchronize.

  • Both source and target systems should contain rsync.
  • The source of files is localhost by default. We can change it using the parameter delegate_to which allows us to copy files from a remote machine to another remote machine.
  • File permissions are of the user who is running the tasks on localhost or remote_user on the Synchronize source machine in the case when delegate_to is used.
  • On Synchronize destination machine, the file’s permission will be remote_user on the destination host or become_user if become=yes is specified in the parameters, but to elevate the permission, passwordless sudo should be configured, as rsync does not provide a way to pass sudo credentials.
  • As of now, the following connection types are only supported with Ansible synchronize: ssh, paramiko, local, and docker.
  • Even if we used sudo, files may be copied to the remote_user home directory, so always provide the full path to the destination host location.
  • The hard link limitations of Linux rsync are also applied here.
  • To avoid a broken state in the event of a connection failure, Ansible synchronizes module forces -delay-updates.

Ansible Synchronize Working

Ansible Synchronize has certain parameters and we can combine those parameters to customize synchronize’s behavior and output of Ansible synchronize.

  • archive: The parameter mirrors the rsync flag, and enables recursive, links, perm, group, owner, and time flags. The default value is set to “yes”.
  • hecksum: This is used to skip based on checksum. The default value is set to “no”.
  • compress: It compresses files during transfer to speed up the transfer. The default value is set to “yes”.
  • copy_links: This is used to copy the referenced items rather than links. The default value is set to “no”.
  • delete: Delete files in the dest location, which does not exist on the source somehow when the transfer is completed. This works when recursive=yes is set. The default value is set to “no”.
  • dest: Represents the absolute or relative path on the destination machine that will sync from the source.
  • src: Represents the absolute or relative path on the source machine that will sync from the destination.
  • dirs: This is used to transfer directories without recursive. The default value is set to “no”.
  • dest_port: Represents a port number of ssh on the destination.
  • link_dest: Adds a destination to hard links against during the rsync. Default value is null.
  • links: The parameter is used to copy syslinks as syslinks, not referenced items.
  • mode: Acceptable values are push and pull. The default value is a push.
  • owner: Preserves owner. The acceptable values are yes and no.
  • rsync_path: The parameter used to specify the rsync command path on remote hosts.
  • times: To preserve the modification times. The acceptable values are yes and no.

[Need help with another query? We’re here to help.]

Conclusion

In this article, we provide a brief description of Ansible Synchronize. We also included the parameters in Synchronize which helps to use Synchronize according to user needs.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.