|
|
@ -15,101 +15,105 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: copy
|
|
|
|
module: copy
|
|
|
|
version_added: "historical"
|
|
|
|
version_added: historical
|
|
|
|
short_description: Copies files to remote locations
|
|
|
|
short_description: Copy files to remote locations
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The C(copy) module copies a file from the local or remote machine to a location on the remote machine.
|
|
|
|
- The C(copy) module copies a file from the local or remote machine to a location on the remote machine.
|
|
|
|
Use the M(fetch) module to copy files from remote locations to the local box.
|
|
|
|
- Use the M(fetch) module to copy files from remote locations to the local box.
|
|
|
|
If you need variable interpolation in copied files, use the M(template) module.
|
|
|
|
- If you need variable interpolation in copied files, use the M(template) module.
|
|
|
|
- For Windows targets, use the M(win_copy) module instead.
|
|
|
|
- For Windows targets, use the M(win_copy) module instead.
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
src:
|
|
|
|
src:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Local path to a file to copy to the remote server; can be absolute or relative.
|
|
|
|
- Local path to a file to copy to the remote server.
|
|
|
|
If path is a directory, it is copied recursively. In this case, if path ends
|
|
|
|
- This 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.
|
|
|
|
with "/", only inside contents of that directory are copied to destination.
|
|
|
|
Otherwise, if it does not end with "/", the directory itself with all contents
|
|
|
|
Otherwise, if it does not end with "/", the directory itself with all contents
|
|
|
|
is copied. This behavior is similar to Rsync.
|
|
|
|
is copied. This behavior is similar to the C(rsync) command line tool.
|
|
|
|
content:
|
|
|
|
content:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- When used instead of I(src), sets the contents of a file directly to the specified value.
|
|
|
|
- When used instead of I(src), sets the contents of a file directly to the specified value.
|
|
|
|
For anything advanced or with formatting also look at the template module.
|
|
|
|
- For anything advanced or with formatting also look at the template module.
|
|
|
|
version_added: "1.1"
|
|
|
|
version_added: '1.1'
|
|
|
|
dest:
|
|
|
|
dest:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- 'Remote absolute path where the file should be copied to. If I(src) is a directory, this must be a directory too.
|
|
|
|
- Remote absolute path where the file should be copied to.
|
|
|
|
If I(dest) is a nonexistent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created.
|
|
|
|
- If I(src) is a directory, this must be a directory too.
|
|
|
|
If I(src) and I(dest) are files, the parent directory of I(dest) isn''t created: the task fails if it doesn''t already exist.'
|
|
|
|
- If I(dest) is a non-existent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created.
|
|
|
|
|
|
|
|
- If I(src) and I(dest) are files, the parent directory of I(dest) is not created and the task fails if it does not already exist.
|
|
|
|
required: yes
|
|
|
|
required: yes
|
|
|
|
backup:
|
|
|
|
backup:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Create a backup file including the timestamp information so you can get
|
|
|
|
- Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
|
|
|
|
the original file back if you somehow clobbered it incorrectly.
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: no
|
|
|
|
version_added: "0.7"
|
|
|
|
version_added: '0.7'
|
|
|
|
force:
|
|
|
|
force:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- the default is C(yes), which will replace the remote file when contents
|
|
|
|
- Influence whether the remote file must always be replaced.
|
|
|
|
are different than the source. If C(no), the file will only be transferred
|
|
|
|
- If C(yes), the remote file will be replaced when contents are different than the source.
|
|
|
|
if the destination does not exist.
|
|
|
|
- If C(no), the file will only be transferred if the destination does not exist.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
default: yes
|
|
|
|
aliases: [ thirsty ]
|
|
|
|
aliases: [ thirsty ]
|
|
|
|
version_added: "1.1"
|
|
|
|
version_added: '1.1'
|
|
|
|
mode:
|
|
|
|
mode:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- "Mode the file or directory should be. For those used to I(/usr/bin/chmod) remember that
|
|
|
|
- The permissions of the destination file or directory.
|
|
|
|
modes are actually octal numbers. You must either add a leading zero so that Ansible's
|
|
|
|
- For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers.
|
|
|
|
YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it
|
|
|
|
You must either add a leading zero so that Ansible's YAML parser knows it is an octal number
|
|
|
|
(like C('644') or C('1777')) so Ansible receives a string and can do its own conversion from
|
|
|
|
(like C(0644) or C(01777))or quote it (like C('644') or C('1777')) so Ansible receives a string
|
|
|
|
string into number. Giving Ansible a number without following one of these rules will end
|
|
|
|
and can do its own conversion from string into number. Giving Ansible a number without following
|
|
|
|
up with a decimal number which will have unexpected results. As of version 1.8, the mode
|
|
|
|
one of these rules will end up with a decimal number which will have unexpected results.
|
|
|
|
may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of
|
|
|
|
- As of Ansible 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)).
|
|
|
|
version 2.3, the mode may also be the special string C(preserve). C(preserve) means that
|
|
|
|
- As of Ansible 2.3, the mode may also be the special string C(preserve).
|
|
|
|
the file will be given the same permissions as the source file."
|
|
|
|
- C(preserve) means that the file will be given the same permissions as the source file.
|
|
|
|
directory_mode:
|
|
|
|
directory_mode:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- When doing a recursive copy set the mode for the directories. If this is not set we will use the system
|
|
|
|
- When doing a recursive copy set the mode for the directories.
|
|
|
|
defaults. The mode is only set on directories which are newly created, and will not affect those that
|
|
|
|
- If this is not set we will use the system defaults.
|
|
|
|
already existed.
|
|
|
|
- The mode is only set on directories which are newly created, and will not affect those that already existed.
|
|
|
|
version_added: "1.5"
|
|
|
|
version_added: '1.5'
|
|
|
|
remote_src:
|
|
|
|
remote_src:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Influence whether I(src) needs to be transferred or already is present remotely.
|
|
|
|
- If C(no), it will search for I(src) at originating/master machine.
|
|
|
|
- If C(no), it will search for I(src) at originating/master machine.
|
|
|
|
- If C(yes) it will go to the remote/target machine for the I(src). Default is C(no).
|
|
|
|
- If C(yes) it will go to the remote/target machine for the I(src).
|
|
|
|
- I(remote_src) supports recursive copying as of version 2.8.
|
|
|
|
- I(remote_src) supports recursive copying as of version 2.8.
|
|
|
|
- I(remote_src) only works with C(mode=preserve) as of version 2.6.
|
|
|
|
- I(remote_src) only works with C(mode=preserve) as of version 2.6.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: no
|
|
|
|
version_added: "2.0"
|
|
|
|
version_added: '2.0'
|
|
|
|
follow:
|
|
|
|
follow:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- This flag indicates that filesystem links in the destination, if they exist, should be followed.
|
|
|
|
- This flag indicates that filesystem links in the destination, if they exist, should be followed.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: no
|
|
|
|
version_added: "1.8"
|
|
|
|
version_added: '1.8'
|
|
|
|
local_follow:
|
|
|
|
local_follow:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- This flag indicates that filesystem links in the source tree, if they exist, should be followed.
|
|
|
|
- This flag indicates that filesystem links in the source tree, if they exist, should be followed.
|
|
|
|
type: bool
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
default: yes
|
|
|
|
version_added: "2.4"
|
|
|
|
version_added: '2.4'
|
|
|
|
checksum:
|
|
|
|
checksum:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- SHA1 checksum of the file being transferred. Used to validate that the copy of the file was successful.
|
|
|
|
- SHA1 checksum of the file being transferred.
|
|
|
|
|
|
|
|
- Used to validate that the copy of the file was successful.
|
|
|
|
- If this is not provided, ansible will use the local calculated checksum of the src file.
|
|
|
|
- If this is not provided, ansible will use the local calculated checksum of the src file.
|
|
|
|
version_added: '2.5'
|
|
|
|
version_added: '2.5'
|
|
|
|
extends_documentation_fragment:
|
|
|
|
extends_documentation_fragment:
|
|
|
|
|
|
|
|
- decrypt
|
|
|
|
- files
|
|
|
|
- files
|
|
|
|
- validate
|
|
|
|
- validate
|
|
|
|
- decrypt
|
|
|
|
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- The M(copy) module recursively copy facility does not scale to lots (>hundreds) of files.
|
|
|
|
- The M(copy) module recursively copy facility does not scale to lots (>hundreds) of files.
|
|
|
|
For alternative, see M(synchronize) module, which is a wrapper around C(rsync).
|
|
|
|
- For alternative, see M(synchronize) module, which is a wrapper around the C(rsync) command line tool.
|
|
|
|
- For Windows targets, use the M(win_copy) module instead.
|
|
|
|
- For Windows targets, use the M(win_copy) module instead.
|
|
|
|
seealso:
|
|
|
|
seealso:
|
|
|
|
- module: assemble
|
|
|
|
- module: assemble
|
|
|
|
|
|
|
|
- module: fetch
|
|
|
|
- module: file
|
|
|
|
- module: file
|
|
|
|
- module: template
|
|
|
|
- module: template
|
|
|
|
- module: win_copy
|
|
|
|
- module: win_copy
|
|
|
@ -119,7 +123,7 @@ author:
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = r'''
|
|
|
|
EXAMPLES = r'''
|
|
|
|
- name: example copying file with owner and permissions
|
|
|
|
- name: Copy file with owner and permissions
|
|
|
|
copy:
|
|
|
|
copy:
|
|
|
|
src: /srv/myfiles/foo.conf
|
|
|
|
src: /srv/myfiles/foo.conf
|
|
|
|
dest: /etc/foo.conf
|
|
|
|
dest: /etc/foo.conf
|
|
|
@ -127,7 +131,7 @@ EXAMPLES = r'''
|
|
|
|
group: foo
|
|
|
|
group: foo
|
|
|
|
mode: 0644
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
|
|
|
|
- name: The same example as above, but using a symbolic mode equivalent to 0644
|
|
|
|
- name: Copy file with owner and permission, using symbolic representation
|
|
|
|
copy:
|
|
|
|
copy:
|
|
|
|
src: /srv/myfiles/foo.conf
|
|
|
|
src: /srv/myfiles/foo.conf
|
|
|
|
dest: /etc/foo.conf
|
|
|
|
dest: /etc/foo.conf
|
|
|
@ -165,7 +169,7 @@ EXAMPLES = r'''
|
|
|
|
remote_src: yes
|
|
|
|
remote_src: yes
|
|
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
validate: /usr/sbin/visudo -cf %s
|
|
|
|
|
|
|
|
|
|
|
|
- name: Copy using the 'content' for inline data
|
|
|
|
- name: Copy using inline content
|
|
|
|
copy:
|
|
|
|
copy:
|
|
|
|
content: '# This file was moved to /etc/other.conf'
|
|
|
|
content: '# This file was moved to /etc/other.conf'
|
|
|
|
dest: /etc/mine.conf
|
|
|
|
dest: /etc/mine.conf
|
|
|
@ -185,62 +189,62 @@ EXAMPLES = r'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = r'''
|
|
|
|
RETURN = r'''
|
|
|
|
dest:
|
|
|
|
dest:
|
|
|
|
description: destination file/path
|
|
|
|
description: Destination file/path
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: /path/to/file.txt
|
|
|
|
sample: /path/to/file.txt
|
|
|
|
src:
|
|
|
|
src:
|
|
|
|
description: source file used for the copy on the target machine
|
|
|
|
description: Source file used for the copy on the target machine
|
|
|
|
returned: changed
|
|
|
|
returned: changed
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source
|
|
|
|
sample: /home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source
|
|
|
|
md5sum:
|
|
|
|
md5sum:
|
|
|
|
description: md5 checksum of the file after running copy
|
|
|
|
description: MD5 checksum of the file after running copy
|
|
|
|
returned: when supported
|
|
|
|
returned: when supported
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: 2a5aeecc61dc98c4d780b14b330e3282
|
|
|
|
sample: 2a5aeecc61dc98c4d780b14b330e3282
|
|
|
|
checksum:
|
|
|
|
checksum:
|
|
|
|
description: sha1 checksum of the file after running copy
|
|
|
|
description: SHA1 checksum of the file after running copy
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
|
|
|
|
sample: 6e642bb8dd5c2e027bf21dd923337cbb4214f827
|
|
|
|
backup_file:
|
|
|
|
backup_file:
|
|
|
|
description: name of backup file created
|
|
|
|
description: Name of backup file created
|
|
|
|
returned: changed and if backup=yes
|
|
|
|
returned: changed and if backup=yes
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: /path/to/file.txt.2015-02-12@22:09~
|
|
|
|
sample: /path/to/file.txt.2015-02-12@22:09~
|
|
|
|
gid:
|
|
|
|
gid:
|
|
|
|
description: group id of the file, after execution
|
|
|
|
description: Group id of the file, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: int
|
|
|
|
type: int
|
|
|
|
sample: 100
|
|
|
|
sample: 100
|
|
|
|
group:
|
|
|
|
group:
|
|
|
|
description: group of the file, after execution
|
|
|
|
description: Group of the file, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: httpd
|
|
|
|
sample: httpd
|
|
|
|
owner:
|
|
|
|
owner:
|
|
|
|
description: owner of the file, after execution
|
|
|
|
description: Owner of the file, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: httpd
|
|
|
|
sample: httpd
|
|
|
|
uid:
|
|
|
|
uid:
|
|
|
|
description: owner id of the file, after execution
|
|
|
|
description: Owner id of the file, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: int
|
|
|
|
type: int
|
|
|
|
sample: 100
|
|
|
|
sample: 100
|
|
|
|
mode:
|
|
|
|
mode:
|
|
|
|
description: permissions of the target, after execution
|
|
|
|
description: Permissions of the target, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: 0644
|
|
|
|
sample: 0644
|
|
|
|
size:
|
|
|
|
size:
|
|
|
|
description: size of the target, after execution
|
|
|
|
description: Size of the target, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: int
|
|
|
|
type: int
|
|
|
|
sample: 1220
|
|
|
|
sample: 1220
|
|
|
|
state:
|
|
|
|
state:
|
|
|
|
description: state of the target, after execution
|
|
|
|
description: State of the target, after execution
|
|
|
|
returned: success
|
|
|
|
returned: success
|
|
|
|
type: string
|
|
|
|
type: string
|
|
|
|
sample: file
|
|
|
|
sample: file
|
|
|
|