file-with-content

Example:

# Create temporary file with some content
- file-with-content:
    path: /tmp/freckles/file_with_content
    content: |
      Hello world!

      I love you!

Description

Ensure a file exists and its content is the one specified as input. Create the necessary user and parent directories if necessary.

If a user is created, it won't have any password set, so you might have to do that in a different (ideally earlier - to have more control) step.

If intermediate parent directories have to be created, they will inherit the owner/group information of the file to be created. If any of those parent directories already exist, they won't be touched at all.

If a owner value is provided, this will use 'root' permissions to (potentially) create the parent folder, and the file.

Variables

Name Type Default Description

content

string --

The file content. Required

path

string --

The path to the file. Required

group

string --

The group of the file.

mode

string --

The permissions of the file.

owner

string --

The owner of the file.

parent_dir_mode

string --

The permissions of the parent directory.

Examples

Example 1

Create temporary file with some content

Code
- file-with-content:
    path: /tmp/freckles/file_with_content
    content: |
      Hello world!

      I love you!

Example 2

Create file with some content, set owner and create that user if necessary

Code
- file-with-content:
    path: /tmp/freckles/another_file
    content: |
      Hello other world!

      I am owned by somebody!
    owner: somebody

Command-line

frecklecute file-with-content --help

Usage: frecklecute file-with-content [OPTIONS] PATH

  Ensure a file exists and its content is the one specified as input. Create
  the necessary user and parent directories if necessary.

  If a user is created, it won't have any password set, so you might have to
  do that in a different (ideally earlier - to have more control) step.

  If intermediate parent directories have to be created, they will inherit
  the owner/group information of the file to be created. If any of those
  parent directories already exist, they won't be touched at all.

  If a ``owner`` value is provided, this will use 'root' permissions to
  (potentially) create the parent folder, and the file.

Options:
  --content CONTENT       The file content.  [required]
  --group GROUP           The group of the file.
  --mode MODE             The permissions of the file.
  --owner USER            The owner of the file.
  --parent-dir-mode MODE  The permissions of the parent directory.
  --help                  Show this message and exit.