New in version 2.2.
Synchronizes the contents of two directories on the remote machine. Under the hood this just calls out to RoboCopy, since that should be available on most modern Windows Systems.
parameter | required | default | choices | comments |
---|---|---|---|---|
dest | yes | Destination file/directory to sync (Will receive contents of src). |
||
flags | no | None | Directly supply Robocopy flags. If set, purge and recurse will be ignored. |
|
purge | no |
| Deletes any files/directories found in the destination that do not exist in the source (Toggles the `/purge` flag to RoboCopy). If "flags" is set, this will be ignored. |
|
recurse | no |
| Includes all subdirectories (Toggles the `/e` flag to RoboCopy). If "flags" is set, this will be ignored. |
|
src | yes | Source file/directory to sync. |
# Syncs the contents of one diretory to another. $ ansible -i hosts all -m win_robocopy -a "src=C:\DirectoryOne dest=C:\DirectoryTwo" # Sync the contents of one directory to another, including subdirectories. $ ansible -i hosts all -m win_robocopy -a "src=C:\DirectoryOne dest=C:\DirectoryTwo recurse=true" # Sync the contents of one directory to another, and remove any files/directories found in destination that do not exist in the source. $ ansible -i hosts all -m win_robocopy -a "src=C:\DirectoryOne dest=C:\DirectoryTwo purge=true" # Sample sync --- - name: Sync Two Directories win_robocopy: src: "C:\DirectoryOne dest: "C:\DirectoryTwo" recurse: true purge: true --- - name: Sync Two Directories win_robocopy: src: "C:\DirectoryOne dest: "C:\DirectoryTwo" recurse: true purge: true flags: '/XD SOME_DIR /XF SOME_FILE /MT:32'
Common return values are documented here Common Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
src | The Source file/directory of the sync. | always | string | c:/Some/Path |
dest | The Destination file/directory of the sync. | always | string | c:/Some/Path |
changed | Whether or not any changes were made. | always | bool | False |
recurse | Whether or not the recurse flag was toggled. | always | bool | False |
return_code | The return code retuned by robocopy. | success | int | 1 |
purge | Whether or not the purge flag was toggled. | always | bool | False |
flags | Any flags passed in by the user. | always | string | /e /purge |
msg | Output intrepreted into a concise message. | always | string | No files copied! |
output | The output of running the robocopy command. | success | string | ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- |
Note
This is not a complete port of the “synchronize” module. Unlike the “synchronize” module this only performs the sync/copy on the remote machine, not from the master to the remote machine.
Note
This module does not currently support all Robocopy flags.
Note
Works on Windows 7, Windows 8, Windows Server 2k8, and Windows Server 2k12
For more information on what this means please read Extras Modules
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.
© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/win_robocopy_module.html