copy

Collection: builtin

Full Name: parallax.builtin.copy

Aliases: ansible.builtin.copy, copy

Synopsis

Copy files from the controller to remote hosts

Parameters

NameTypeRequiredDefaultDescription
srcstringLocal path to a file or directory to copy to the remote server (required if content is not provided)
deststringyesRemote absolute path where the file should be copied to
modestringThe permission mode of the destination file
ownerstringName or numeric id of the user that should own the file
groupstringName or numeric id of the group that should own the file
contentstringContent to copy to the destination instead of a file (mutually exclusive with src)
backupboolfalseCreate a timestamped backup of the destination before overwriting it
forcebooltrueReplace the destination when it already exists and differs. When false an existing destination is left alone
followboolfalseFollow symlinks on the destination when applying ownership
remote_srcboolfalseTreat src as a path on the target rather than on the controller
validatestringCommand run against the staged file before it is moved into place; %s is replaced with the staged path
directory_modestringPermission mode applied to directories created by a recursive copy
checksumstringExpected checksum of the source file (sha1, sha256 or sha512, given as hex)
preserve_modeboolfalseTake 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"