New in version 1.9.2.
parameter | required | default | choices | comments |
---|---|---|---|---|
content (added in 2.3) |
no | When used instead of 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. | ||
dest |
yes | 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". | ||
force (added in 2.3) |
no | True |
|
If set to yes , the remote file will be replaced when content is different than the source.If set to no , the remote file will only be transferred if the destination does not exist. |
remote_src (added in 2.3) |
no |
|
If False, it will search for src at originating/master machine, if True it will go to the remote/target machine for the src. | |
src |
yes | Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync. |
- name: Copy a single file win_copy: src: /srv/myfiles/foo.conf dest: c:\Temp\foo.conf - name: Copy files/temp_files to c:\temp 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
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
src | source file used for the copy on the target machine | changed | string | /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source |
original_basename | basename of the copied file | changed, src is a file | string | foo.txt |
dest | destination file/path | changed | string | C:\Temp\ |
checksum | sha1 checksum of the file after running copy | success, src is a file | string | 6e642bb8dd5c2e027bf21dd923337cbb4214f827 |
operation | whether a single file copy took place or a folder copy | changed | string | file_copy |
size | size of the target, after execution | changed (src is a file or remote_src == True) | int | 1220 |
This module is flagged as stableinterface which means that the maintainers for this module guarantee that no backward incompatible interface changes will be made.
This module is maintained by those with core commit privileges
For more information on what this means please read Module Support
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.