parent-folder-exists

Example:

# Create parent folder for a path.
- parent-folder-exists:
    path: /tmp/parent_1/parent_2/freckles.txt

Description

Ensure the parent folder of a path exists. If the owner and/or group variables is/are specified, those will be created if they don't exist yet and set alongside the mode for that folder.

If the parent folder already exists and owner/group/mode attributes are provided, those won't be applied.

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

path

string --

The path to the child file/folder. Required

group

string --

The group of the folder, will be created if necessary.

mode

string --

The permissions of the folder.

owner

string --

The owner of the folder, will be created if necessary.

system_user

boolean --

Whether the user and group should be of system user/group type.

Examples

Example 1

Create parent folder for a path.

Code
- parent-folder-exists:
    path: /tmp/parent_1/parent_2/freckles.txt
Description

Create folder /tmp/parent_1/parent_2. Doesn't do anything else, like 'touching' the freckles.txt file.

Command-line

frecklecute parent-folder-exists --help

Usage: frecklecute parent-folder-exists [OPTIONS] PATH

  Ensure the parent folder of a path exists. If the ``owner`` and/or
  ``group`` variables is/are specified, those will be created if they don't
  exist yet and set alongside the mode for that folder.

  If the parent folder already exists and owner/group/mode attributes are
  provided, those won't be applied.

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

Options:
  --group GROUP_NAME              The group of the folder, will be created if
                                  necessary.
  --mode MODE                     The permissions of the folder.
  --owner USER_NAME               The owner of the folder, will be created if
                                  necessary.
  --system-user / --no-system-user
                                  Whether the user and group should be of
                                  system user/group type.
  --help                          Show this message and exit.