1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

correctly quote labels and environment variables for quadlets (#920)

Fixes: #807

Signed-off-by: Evgeni Golov <evgeni@golov.de>
This commit is contained in:
Evgeni Golov 2025-04-14 13:47:20 +02:00 committed by GitHub
parent 40d320d8f6
commit 6946a0bcbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import os
import shlex
from ansible_collections.containers.podman.plugins.module_utils.podman.common import compare_systemd_file_content
@ -169,9 +170,9 @@ class ContainerQuadlet(Quadlet):
if isinstance(params["command"], list)
else params["command"])
if params["label"]:
params["label"] = ["%s=%s" % (k, v) for k, v in params["label"].items()]
params["label"] = [shlex.quote("%s=%s" % (k, v)) for k, v in params["label"].items()]
if params["env"]:
params["env"] = ["%s=%s" % (k, v) for k, v in params["env"].items()]
params["env"] = [shlex.quote("%s=%s" % (k, v)) for k, v in params["env"].items()]
if params["rootfs"]:
params["rootfs"] = params["image"]
params["image"] = None

View file

@ -1293,9 +1293,11 @@
BAR: foo
TEST: 1
BOOL: false
WITH_SPACES: "a nice string"
label:
somelabel: labelvalue
otheralbe: othervalue
spacelabel: "a nice label"
log_opt:
max_size: 10mb
path: /var/log/container/mycontainer.json
@ -1347,9 +1349,11 @@
- "Unmask=ALL"
- "SecurityLabelFileType=usr_t"
- "Environment=BOOL=False"
- "Environment='WITH_SPACES=a nice string'"
- "PublishPort=9001:8000"
- "AddHost=host2:127.0.0.1"
- "Label=somelabel=labelvalue"
- "Label='spacelabel=a nice label'"
- "WantedBy=default.target"
- "GroupAdd=admin"
- "GroupAdd=users"
@ -1411,9 +1415,11 @@
BAR: foo
TEST: 1
BOOL: false
WITH_SPACES: "a nice string"
label:
somelabel: labelvalue
otheralbe: othervalue
spacelabel: "a nice label"
log_opt:
max_size: 10mb
path: /var/log/container/mycontainer.json