Synchronizes the contents of two directories using Robocopy
- Synchronizes the contents of files/directories from a source to destination.
- Under the hood this just calls out to RoboCopy, since that should be available on most modern Windows systems.
Note
- This is not a complete port of the :ref:`ansible.posix.synchronize <ansible.posix.synchronize_module>` module. Unlike the :ref:`ansible.posix.synchronize <ansible.posix.synchronize_module>` module this only performs the sync/copy on the remote machine, not from the Ansible controller to the remote machine.
- This module does not currently support all Robocopy flags.
.. seealso:: :ref:`ansible.posix.synchronize_module` The official documentation on the **ansible.posix.synchronize** module. :ref:`ansible.windows.win_copy_module` The official documentation on the **ansible.windows.win_copy** module.
- name: Sync the contents of one directory to another
community.windows.win_robocopy:
src: C:\DirectoryOne
dest: C:\DirectoryTwo
- name: Sync the contents of one directory to another, including subdirectories
community.windows.win_robocopy:
src: C:\DirectoryOne
dest: C:\DirectoryTwo
recurse: yes
- name: Sync the contents of one directory to another, and remove any files/directories found in destination that do not exist in the source
community.windows.win_robocopy:
src: C:\DirectoryOne
dest: C:\DirectoryTwo
purge: yes
- name: Sync content in recursive mode, removing any files/directories found in destination that do not exist in the source
community.windows.win_robocopy:
src: C:\DirectoryOne
dest: C:\DirectoryTwo
recurse: yes
purge: yes
- name: Sync two directories in recursive and purging mode, specifying additional special flags
community.windows.win_robocopy:
src: C:\DirectoryOne
dest: C:\DirectoryTwo
flags: /E /PURGE /XD SOME_DIR /XF SOME_FILE /MT:32
- name: Sync one file from a remote UNC path in recursive and purging mode, specifying additional special flags
community.windows.win_robocopy:
src: \\Server1\Directory One
dest: C:\DirectoryTwo
flags: file.zip /E /PURGE /XD SOME_DIR /XF SOME_FILE /MT:32
Common return values are documented here, the following are the fields unique to this module:
- Corwin Brown (@blakfeld)