File

The file resource manages files and directories, including their content, ownership, and permissions.

Warning

Use absolute file paths and primary group names.

- file:
    - /etc/motd:
        ensure: present
        content: |
          Managed by CCM {{ now() }}
        owner: root
        group: root
        mode: "0644"
ccm ensure file /etc/motd --source /tmp/ccm/motd --owner root --group root --mode 0644
{
  "protocol": "io.choria.ccm.v1.resource.ensure.request",
  "type": "file",
  "properties": {
    "name": "/etc/motd",
    "ensure": "present",
    "content": "Managed by CCM\n",
    "owner": "root",
    "group": "root",
    "mode": "0644"
  }
}

This copies the contents of /tmp/ccm/motd to /etc/motd verbatim and sets ownership.

Use --content or --content-file to parse content through the template engine before writing.

Ensure Values

ValueDescription
presentThe file must exist
absentThe file must not exist
directoryThe path must be a directory

Properties

PropertyDescription
nameAbsolute path to the file
ensureDesired state (present, absent, directory)
contentFile contents, parsed through the template engine
sourceCopy contents from another local file
ownerFile owner (username)
groupFile group (group name)
modeFile permissions in octal notation (e.g., "0644")
providerForce a specific provider (posix only)