sr2c.podman.safe_directory module – Create a directory under a base directory without following symbolic links
Note
This module is part of the sr2c.podman collection (version 0.0.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install sr2c.podman.
To use it in a playbook, specify: sr2c.podman.safe_directory.
New in sr2c.podman 0.0.1
Synopsis
Creates a directory at path under base, with the given owner, group and mode, along with any missing parent directories between them, without following a symbolic link anywhere below base.
Intended for running as root in a directory another user controls, such as a rootless Podman user’s home directory. With ansible.builtin.file, a symbolic link the user planted there, or a symbolic link in place of a parent directory, could make root create or chown something anywhere on the host. This module opens each part of the path relative to the one before it, refusing symbolic links, and changes the directory through the open file descriptor, so nothing can be swapped in between the check and the change.
base itself is trusted and may be reached through a symbolic link, such as
/homepointing at/var/home.Owner, group and mode apply to the directory itself, not to its contents. Parent directories that already exist are left as they are.
Linux only.
Parameters
Parameter |
Comments |
|---|---|
The absolute path of the directory to work under, for example a user’s home directory. It must already exist. |
|
The directory’s group, as a numeric group ID. |
|
The directory’s mode, as an octal string such as |
|
The directory’s owner, as a numeric user ID. |
|
The group of parent directories this module creates, as a numeric group ID. Defaults to the group of base. |
|
The mode of parent directories this module creates. Default: |
|
The owner of parent directories this module creates, as a numeric user ID. Defaults to the owner of base. |
|
The directory to create, relative to base, for example Absolute paths, empty parts, and |
Notes
Note
Supports check mode. A directory that doesn’t exist yet is reported as changed, without checking anything below it.
Examples
- name: Create a data directory owned by a subordinate UID
sr2c.podman.safe_directory:
base: /home/app_link
path: opensearch/data
owner: 200999
group: 200999
mode: "0750"
become: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
The parts of path this module created, outermost first. Returned: success Sample: |
|
The directory’s full path. Returned: success Sample: |