copy Module

May 8, 2026 ยท View on GitHub

Copy files, directories, or inline content to the connected target host.

Parameters

ParameterDescriptionTypeRequiredDefault
srcSource file or directory pathstringNo (required when content is empty)-
contentInline content, written directly to targetstringNo (required when src is empty)-
destPath on target hoststringYes-
  • Relative paths are relative to the files directory for the current task; task path is specified by the task's annotation kubesphere.io/rel-path.
  • Absolute paths can also be used to point to local files or directories.

Examples

1. Copy relative path file

- name: copy relative path
  copy:
    src: a.yaml
    dest: /tmp/b.yaml

2. Copy absolute path file

- name: copy absolute path
  copy:
    src: /tmp/a.yaml
    dest: /tmp/b.yaml

3. Copy directory

Copies all files and subdirectories in the directory to the target host.

- name: copy dir
  copy:
    src: /tmp
    dest: /tmp

4. Copy inline content

- name: copy content
  copy:
    content: hello
    dest: /tmp/b.txt