From 681280463d996a053d3e3e19eeaba15c31f34d61 Mon Sep 17 00:00:00 2001 From: dada513 Date: Sat, 28 May 2022 18:49:44 +0200 Subject: [PATCH] generate_systemd: implement --wants, --after and --requires (GH-431) Signed-off-by: dada513 --- plugins/module_utils/podman/common.py | 9 +++++++++ plugins/modules/podman_container.py | 15 +++++++++++++++ plugins/modules/podman_pod.py | 15 +++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/plugins/module_utils/podman/common.py b/plugins/module_utils/podman/common.py index d10d95045..977991fc5 100644 --- a/plugins/module_utils/podman/common.py +++ b/plugins/module_utils/podman/common.py @@ -54,6 +54,15 @@ def generate_systemd(module, module_params, name): command.extend(['--pod-prefix=%s' % sysconf['pod_prefix']]) if sysconf.get('separator') is not None: command.extend(['--separator=%s' % sysconf['separator']]) + if sysconf.get('after') is not None: + for after in sysconf['after']: + command.extend(['--after=%s' % after]) + if sysconf.get('wants') is not None: + for want in sysconf['wants']: + command.extend(['--wants=%s' % want]) + if sysconf.get('requires') is not None: + for require in sysconf['requires']: + command.extend(['--requires=%s' % require]) if module.params['debug'] or module_params['debug']: module.log("PODMAN-CONTAINER-DEBUG: systemd command: %s" % " ".join(command)) diff --git a/plugins/modules/podman_container.py b/plugins/modules/podman_container.py index 2d76ae13a..5cd04ebc1 100644 --- a/plugins/modules/podman_container.py +++ b/plugins/modules/podman_container.py @@ -358,6 +358,21 @@ Refer to podman-generate-systemd(1) for more information. type: bool default: false + after: + type: list + required: false + description: + - Add the systemd unit after (After=) option, that ordering dependencies between the list of dependencies and this service. + wants: + type: list + required: false + description: + - Add the systemd unit wants (Wants=) option, that this service is (weak) dependent on. + requires: + type: list + required: false + description: + - Set the systemd unit requires (Requires=) option. Similar to wants, but declares a stronger requirement dependency. gidmap: description: - Run the container in a new user namespace using the supplied mapping. diff --git a/plugins/modules/podman_pod.py b/plugins/modules/podman_pod.py index 75c516122..f45dc4db5 100644 --- a/plugins/modules/podman_pod.py +++ b/plugins/modules/podman_pod.py @@ -163,6 +163,21 @@ Refer to podman-generate-systemd(1) for more information. type: bool default: false + after: + type: list + required: false + description: + - Add the systemd unit after (After=) option, that ordering dependencies between the list of dependencies and this service. + wants: + type: list + required: false + description: + - Add the systemd unit wants (Wants=) option, that this service is (weak) dependent on. + requires: + type: list + required: false + description: + - Set the systemd unit requires (Requires=) option. Similar to wants, but declares a stronger requirement dependency. gidmap: description: - GID map for the user namespace. Using this flag will run the container with