ansible / ansible.builtin / v2.3.2.0-1 / 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.3.2.0-1) — module
pip
Install with pip install ansible==2.3.2.0.post1
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.
- 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: True
- 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: True
- 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: True purge: True
- 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
src: description: - Source file/directory to sync. required: true dest: description: - Destination file/directory to sync (Will receive contents of src). required: true flags: default: None description: - Directly supply Robocopy flags. If set, purge and recurse will be ignored. required: false purge: choices: - true - false default: false description: - 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. required: false recurse: choices: - true - false default: false description: - Includes all subdirectories (Toggles the `/e` flag to RoboCopy). If "flags" is set, this will be ignored. required: false
changed: description: Whether or not any changes were made. returned: always sample: false type: bool dest: description: The Destination file/directory of the sync. returned: always sample: c:\Some\Path type: string flags: description: Any flags passed in by the user. returned: always sample: /e /purge type: string msg: description: Output intrepreted into a concise message. returned: always sample: No files copied! type: string output: description: The output of running the robocopy command. returned: success sample: "-------------------------------------------------------------------------------\n\ \ ROBOCOPY :: Robust File Copy for Windows \ \ \n-------------------------------------------------------------------------------\n" type: string purge: description: Whether or not the purge flag was toggled. returned: always sample: false type: bool rc: description: The return code retuned 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: string