folder-exists

Example:

# Create a folder if it doesn't exist yet, including owner and group if necessary.
- folder-exists:
    path: /tmp/freckles
    owner: freckles
    group: wheel

Description

Ensure a folder exists on the filesystem

If the owner and/or group variables is/are specified, create those in case they don't exist yet.

If the owner variable is specified, this frecklet will use elevated permissions.

Variables

Name Type Default Description

path

string --

The path to the folder. Required

force_chown

boolean True

Whether to force changing of ownership, even if folder already exists.

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 False

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

Examples

Example 1

Create a folder if it doesn't exist yet, including owner and group if necessary.

Code
- folder-exists:
    path: /tmp/freckles
    owner: freckles
    group: wheel

Example 2

Create a folder if it doesn't exist yet.

Code
- folder-exists:
    path: /tmp/freckles

Example 3

Create a folder incl. parent folders if necessary.

Code
- folder-exists:
    path: /tmp/parent_1/parent_2/freckles

Command-line

frecklecute folder-exists --help

Usage: frecklecute folder-exists [OPTIONS] PATH

  Ensure a folder exists on the filesystem

  If the ``owner`` and/or ``group`` variables is/are specified, create those
  in case they don't exist yet.

  If the ``owner`` variable is specified, this frecklet will use elevated
  permissions.

Options:
  --force-chown / --no-force-chown
                                  Whether to force changing of ownership, even
                                  if folder already exists.
  --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.