Skip to main content

copy

copy module

Copy files from the local machine to the target host. You can copy files from a source path or provide content directly.

Examples

- name: Copy a file
copy:
src: /path/to/local/file.txt
dest: /path/to/remote/file.txt
mode: '0644'

- name: Copy with inline content
copy:
content: |
Hello World
This is file content
dest: /tmp/hello.txt
mode: '0644'

- name: Copy from role files directory
copy:
src: config.conf
dest: /etc/myapp/config.conf

Note: When used in roles, the copy module will first look for files in the role's files/ directory before checking other locations.

Module Capabilities

  • Has Revert: true
  • Provides Variables: None

Inputs

ParameterTypeDescriptionRequiredDefaultChoices
contentstringContent to write directly to the destination file. Cannot be used with 'src'.false
deststringPath to the destination file on the target host.true
modestringFile permissions to set on the destination file (e.g., '0644', '0755').false
srcstringPath to the source file on the local machine. Cannot be used with 'content'.false

Outputs

No outputs.