copy
Collection: builtin
Full Name: parallax.builtin.copy
Aliases: ansible.builtin.copy, copy
Synopsis
Copy files from the controller to remote hosts
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| src | string | Local path to a file or directory to copy to the remote server (required if content is not provided) | ||
| dest | string | yes | Remote absolute path where the file should be copied to | |
| mode | string | The permission mode of the destination file | ||
| owner | string | Name or numeric id of the user that should own the file | ||
| group | string | Name or numeric id of the group that should own the file | ||
| content | string | Content to copy to the destination instead of a file (mutually exclusive with src) | ||
| backup | bool | false | Create a timestamped backup of the destination before overwriting it | |
| force | bool | true | Replace the destination when it already exists and differs. When false an existing destination is left alone | |
| follow | bool | false | Follow symlinks on the destination when applying ownership | |
| remote_src | bool | false | Treat src as a path on the target rather than on the controller | |
| validate | string | Command run against the staged file before it is moved into place; %s is replaced with the staged path | ||
| directory_mode | string | Permission mode applied to directories created by a recursive copy | ||
| checksum | string | Expected checksum of the source file (sha1, sha256 or sha512, given as hex) | ||
| preserve_mode | bool | false | Take the destination mode from the source file rather than the remote default |
Example
- name: Install a config file with explicit ownership
copy:
src: files/app.conf
dest: /etc/app/app.conf
owner: root
group: root
mode: "0644"
backup: true
- name: Write a short file from inline content
copy:
dest: /etc/motd
content: "Managed by Parallax\n"
mode: "0644"