(added in 2.3)
Attributes the file or directory should have. To get supported flags look at the man page for chattr on the target system. This string should contain the attributes in the same order as the one displayed by lsattr.
Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
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.
Remote absolute path where the file should be copied to. If src is a directory, this must be a directory too.
(added in 1.5)
When doing a recursive copy set the mode for the directories. If this is not set we will use the system defaults. The mode is only set on directories which are newly created, and will not affect those that already existed.
(added in 1.8)
This flag indicates that filesystem links, if they exist, should be followed.
the default is
Name of the group that should own the file/directory, as would be fed to chown.
Mode the file or directory should be. For those used to /usr/bin/chmod remember that modes are actually octal numbers (like 0644). Leaving off the leading zero will likely have unexpected results. As of version 1.8, the mode may be specified as a symbolic mode (for example,
Name of the user that should own the file/directory, as would be fed to chown.
(added in 2.0)
If False, it will search for src at originating/master machine, if True it will go to the remote/target machine for the src. Default is False.
Currently remote_src does not support recursive copying.
Level part of the SELinux file context. This is the MLS/MCS attribute, sometimes known as the
Role part of SELinux file context,
Type part of SELinux file context,
User part of SELinux file context. Will default to system policy, if applicable. If set to
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.
(added in 2.2)
Normally this module uses atomic operations to prevent data corruption or inconsistent reads from the target files, sometimes systems are configured or just broken in ways that prevent this. One example are docker mounted files, they cannot be updated atomically and can only be done in an unsafe manner.
This boolean option allows ansible to fall back to unsafe methods of updating files for those cases in which you do not have any other choice. Be aware that this is subject to race conditions and can lead to data corruption.
The validation command to run before copying into place. The path to the file to validate is passed in via '%s' which must be present as in the example below. The command is passed securely so shell features like expansion and pipes won't work.
# Example from Ansible Playbooks - copy: src: /srv/myfiles/foo.conf dest: /etc/foo.conf owner: foo group: foo mode: 0644 # The same example as above, but using a symbolic mode equivalent to 0644 - copy: src: /srv/myfiles/foo.conf dest: /etc/foo.conf owner: foo group: foo mode: "u=rw,g=r,o=r" # Another symbolic mode example, adding some permissions and removing others - copy: src: /srv/myfiles/foo.conf dest: /etc/foo.conf owner: foo group: foo mode: "u+rw,g-wx,o-rwx" # Copy a new "ntp.conf file into place, backing up the original if it differs from the copied version - copy: src: /mine/ntp.conf dest: /etc/ntp.conf owner: root group: root mode: 0644 backup: yes # Copy a new "sudoers" file into place, after passing validation with visudo - copy: src: /mine/sudoers dest: /etc/sudoers validate: 'visudo -cf %s' # Copy a "sudoers" file on the remote machine for editing - copy: remote_src: true src: /etc/sudoers dest: /etc/sudoers.edit
Common return values are documented here Return Values, the following are the fields unique to this module:
|src||source file used for the copy on the target machine||changed||string||/home/httpd/.ansible/tmp/ansible-tmp-1423796390.97-147729857856000/source|
|backup_file||name of backup file created||changed and if backup=yes||string||/path/to/[email protected]:09~|
|uid||owner id of the file, after execution||success||int||100|
|checksum||sha1 checksum of the file after running copy||success||string||6e642bb8dd5c2e027bf21dd923337cbb4214f827|
|md5sum||md5 checksum of the file after running copy||when supported||string||2a5aeecc61dc98c4d780b14b330e3282|
|state||state of the target, after execution||success||string||file|
|gid||group id of the file, after execution||success||int||100|
|mode||permissions of the target, after execution||success||string||0644|
|owner||owner of the file, after execution||success||string||httpd|
|group||group of the file, after execution||success||string||httpd|
|size||size of the target, after execution||success||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.