ansible / ansible.builtin / v2.9.27 / module / win_robocopy Synchronizes the contents of two directories using Robocopy | "added in version" 2.2 of ansible.builtin" Authors: Corwin Brown (@blakfeld) preview | supported by communityansible.builtin.win_robocopy (v2.9.27) — module
pip
Install with pip install ansible==2.9.27
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.
- name: Sync the contents of one directory to another win_robocopy: src: C:\DirectoryOne dest: C:\DirectoryTwo
- name: Sync the contents of one directory to another, including subdirectories 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 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 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 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 win_robocopy: src: \\Server1\Directory One dest: C:\DirectoryTwo flags: file.zip /E /PURGE /XD SOME_DIR /XF SOME_FILE /MT:32
src: description: - Source file/directory to sync. required: true type: path dest: description: - Destination file/directory to sync (Will receive contents of src). required: true type: path flags: description: - Directly supply Robocopy flags. - If set, C(purge) and C(recurse) will be ignored. type: str purge: default: false description: - Deletes any files/directories found in the destination that do not exist in the source. - Toggles the C(/purge) flag to RoboCopy. - If C(flags) is set, this will be ignored. type: bool recurse: default: false description: - Includes all subdirectories (Toggles the C(/e) flag to RoboCopy). - If C(flags) is set, this will be ignored. type: bool
cmd: description: The used command line. returned: always sample: robocopy C:\DirectoryOne C:\DirectoryTwo /e /purge type: str dest: description: The Destination file/directory of the sync. returned: always sample: C:\Some\Path type: str flags: description: Any flags passed in by the user. returned: always sample: /e /purge type: str msg: description: Output interpreted into a concise message. returned: always sample: No files copied! type: str output: description: The output of running the robocopy command. returned: success sample: '------------------------------------\n ROBOCOPY :: Robust File Copy for Windows \n------------------------------------\n ' type: str purge: description: Whether or not the purge flag was toggled. returned: always sample: false type: bool rc: description: The return code returned by robocopy. returned: success sample: 1 type: int recurse: description: Whether or not the recurse flag was toggled. returned: always sample: false type: bool src: description: The Source file/directory of the sync. returned: always sample: C:\Some\Path type: str