ansible / ansible.builtin / v2.4.4.0-1 / module / win_copy Copies files to remote locations on windows hosts | "added in version" 1.9.2 of ansible.builtin" Authors: Jon Hawkesworth (@jhawkesworth), Jordan Borean (@jborean93) stableinterface | supported by coreansible.builtin.win_copy (v2.4.4.0-1) — module
pip
Install with pip install ansible==2.4.4.0.post1
The C(win_copy) module copies a file on the local box to remote windows locations.
For non-Windows targets, use the M(copy) module instead.
- name: Copy a single file win_copy: src: /srv/myfiles/foo.conf dest: c:\Temp\renamed-foo.conf
- name: Copy a single file keeping the filename win_copy: src: /src/myfiles/foo.conf dest: c:\temp\
- name: Copy folder to c:\temp (results in C:\Temp\temp_files) win_copy: src: files/temp_files dest: c:\Temp
- name: Copy folder contents recursively win_copy: src: files/temp_files/ dest: c:\Temp
- name: Copy a single file where the source is on the remote host win_copy: src: C:\temp\foo.txt dest: C:\ansible\foo.txt remote_src: True
- name: Copy a folder recursively where the source is on the remote host win_copy: src: C:\temp dest: C:\ansible remote_src: True
- name: Set the contents of a file win_copy: dest: C:\temp\foo.txt content: abc123
src: description: - Local path to a file to copy to the remote server; can be absolute or relative. - If path is a directory, it is copied (including the source folder name) recursively to C(dest). - If path is a directory and ends with "/", only the inside contents of that directory are copied to the destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. - If path is a file and dest ends with "\", the file is copied to the folder with the same filename. required: true dest: description: - Remote absolute path where the file should be copied to. If src is a directory, this must be a directory too. - Use \ for path separators or \\ when in "double quotes". - If C(dest) ends with \ then source or the contents of source will be copied to the directory without renaming. - If C(dest) is a nonexistent path, it will only be created if C(dest) ends with "/" or "\", or C(src) is a directory. - If C(src) and C(dest) are files and if the parent directory of C(dest) doesn't exist, then the task will fail. required: true force: default: 'yes' description: - If set to C(yes), the file will only be transferred if the content is different than destination. - If set to C(no), the file will only be transferred if the destination does not exist. - If set to C(no), no checksuming of the content is performed which can help improve performance on larger files. type: bool version_added: '2.3' version_added_collection: ansible.builtin content: description: - When used instead of C(src), sets the contents of a file directly to the specified value. This is for simple values, for anything complex or with formatting please switch to the template module. version_added: '2.3' version_added_collection: ansible.builtin remote_src: default: 'no' description: - If False, it will search for src at originating/master machine, if True it will go to the remote/target machine for the src. type: bool version_added: '2.3' version_added_collection: ansible.builtin local_follow: default: 'yes' description: - This flag indicates that filesystem links in the source tree, if they exist, should be followed. type: bool version_added: '2.4' version_added_collection: ansible.builtin
checksum: description: sha1 checksum of the file after running copy returned: success, src is a file sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827 type: string dest: description: destination file/path returned: changed sample: C:\Temp\ type: string operation: description: whether a single file copy took place or a folder copy returned: success sample: file_copy type: string original_basename: description: basename of the copied file returned: changed, src is a file sample: foo.txt type: string size: description: size of the target, after execution returned: changed, src is a file sample: 1220 type: int src: description: source file used for the copy on the target machine returned: changed sample: /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source type: string