mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Add podman Quadlet modules
This commit introduces two new modules for managing Podman Quadlets: - podman_quadlet: Install and remove Podman Quadlet files * Supports installing single files, directories, and additional config files * Implements idempotent state management (present/absent) * Validates parameters and provides meaningful error messages * Default force=true for removal operations * Removed deprecated 'ignore' parameter in favor of built-in idempotency - podman_quadlet_info: Gather information about installed Quadlets * Lists all installed quadlets or prints specific quadlet content * Supports filtering by quadlet kinds (container, pod, network, etc.) * Provides detailed quadlet metadata including status and paths Key features: - Shared utilities in module_utils/podman/quadlet.py for code reuse - Comprehensive integration tests for both modules - Full idempotency support for all operations - Proper handling of edge cases (missing files, malformed quadlets, etc.) - Check mode support for safe dry-run operations - Extensive documentation and examples The modules use relative imports for module_utils to support local development and testing with the containers.podman collection. Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
a808c18fbc
commit
09bb5454a9
9 changed files with 2091 additions and 0 deletions
|
|
@ -15,6 +15,30 @@ from ansible_collections.containers.podman.plugins.module_utils.podman.common im
|
|||
QUADLET_ROOT_PATH = "/etc/containers/systemd/"
|
||||
QUADLET_NON_ROOT_PATH = "~/.config/containers/systemd/"
|
||||
|
||||
# https://github.com/containers/podman/blob/main/pkg/systemd/quadlet/quadlet_common.go
|
||||
QUADLET_SUFFIXES = [
|
||||
".artifact",
|
||||
".container",
|
||||
".volume",
|
||||
".kube",
|
||||
".network",
|
||||
".image",
|
||||
".build",
|
||||
".pod",
|
||||
".quadlets",
|
||||
]
|
||||
|
||||
|
||||
def resolve_quadlet_dir(module):
|
||||
quadlet_dir = module.params.get("quadlet_dir")
|
||||
if not quadlet_dir:
|
||||
user_is_root = os.geteuid() == 0
|
||||
if user_is_root:
|
||||
quadlet_dir = QUADLET_ROOT_PATH
|
||||
else:
|
||||
quadlet_dir = os.path.expanduser(QUADLET_NON_ROOT_PATH)
|
||||
return quadlet_dir
|
||||
|
||||
|
||||
class Quadlet:
|
||||
param_map = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue