sr2c.podman.podman_data role – Create the data directories a rootless Podman stack mounts as volumes
Note
This role 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.podman_data.
Entry point main – Create the data directories a rootless Podman stack mounts as volumes
Synopsis
Creates the directories in
podman_data_podman_rootless_user‘s home that the stack’s containers mount as volumes, with the owner, group and mode they need for inside the container.Owners and groups are given as the IDs inside the container, and the role works out the IDs on the host from the user’s subordinate ID ranges, as reported by
getsubids, so it works for users from FreeIPA as well as local users. ID0is the rootless user. IDs from1up are the user’s subordinate ranges joined in order, as Podman maps them.The rootless user controls its home directory, so the directories are created with sr2c.podman.safe_directory, which refuses to follow a symbolic link anywhere below the home directory. A symbolic link where a directory or one of its parents should be fails the run. The quotas are refused, too, for a directory reached through a symbolic link under the home directory.
Owner, group and mode apply to each directory itself, not to its contents. Parent directories that are not listed themselves are created, if missing, owned by the rootless user with mode
0755.Data directories are never removed. One taken out of
podman_data_directoriesstays on disk, with its data, until it is removed by hand.Directories with a
quotaget an XFS project quota, following the identifiers conventions on devops.sr2.uk. Each is a project named<stack>_<component>, where the component is the directory’s path with/,-and.turned into_, recorded in/etc/projidand/etc/projects. A project keeps its ID, and a new one gets the lowest free ID in the stack’s range,<number> x 1000to<number> x 1000 + 999. The filesystem holding the home directory must be XFS mounted with project quotas (pquotaorprjquota).The projects in the stack’s namespace, named
<stack>or<stack>_*, belong to this role. Any of them no longer wanted has its limit cleared, its directory taken out of the project, and its lines removed from/etc/projidand/etc/projects, as are lines in/etc/projectswith an ID in the stack’s range that no wanted project uses. Projects outside the namespace are left alone. A line in/etc/projidwhose name and ID disagree about which stack owns it fails the run.Run sr2c.podman.podman_host for the user first.
Parameters
Parameter |
Comments |
|---|---|
The directories, keyed by their path relative to the user’s home directory, for example Each value is a dictionary with
Default: |
|
The rootless Podman user whose home directory holds the data directories. |
|
The stack name from the registry on the identifiers page, such as Required when any directory has a quota. When it is set, every project in the stack’s namespace that isn’t wanted is removed, including when no directory has a quota. |
|
The stack’s number from the registry on the identifiers page, such as Required along with |