Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the difference between ansible fetch and ansible synchronize?


Asked by Lewis Bishop on Nov 29, 2021 FAQ



While we are already aware of what is Ansible Copy module is used for. Here is the Simple introduction to Ansible Fetch and Ansible Synchronize. Ansible Fetch is to pull the files from the remote server to the control machine. Ansible Synchronize is used to copy the files between remote servers (or) target hosts.
Besides,
To efficiently use Ansible fetch module, one much learn about all available parameters, their acceptable values. Also, there are some parameters that have default values set always, which will be realized to your playbook even if you do not mention the related parameter in the playbook. So these become more important to know.
Thereof, Currently, we have only below few connection types to work with Ansible synchronize viz are ssh, paramiko, local, and docker. Always give the full path of the destination host location, as there may be cases where you used sudo, but files will be copied to remote_user home directory.
Next,
This module works like ansible.builtin.copy, but in reverse. It is used for fetching files from remote machines and storing them locally in a file tree, organized by hostname. Files that already exist at dest will be overwritten if they are different than the src.
One may also ask,
This will cause the playbook failure when Ansible is unable to read files on source systems, reason can be anything like permission, non-existence, etc. Available values are yes and no. flat: Default is no. Acceptable values are yes and no. This is to set the override the default behavior of the fetch module.