diff --git a/plugins/module_utils/podman/quadlet.py b/plugins/module_utils/podman/quadlet.py index 3ed43a8a..11efee70 100644 --- a/plugins/module_utils/podman/quadlet.py +++ b/plugins/module_utils/podman/quadlet.py @@ -108,6 +108,7 @@ class ContainerQuadlet(Quadlet): 'ip6': 'IP6', 'label': 'Label', 'log_driver': 'LogDriver', + 'log_opt': 'LogOpt', "Mask": "Mask", # add it in security_opt 'mount': 'Mount', 'network': 'Network', @@ -284,8 +285,7 @@ def custom_prepare_params(self, params: dict) -> dict: if params["label_file"]: params["podman_args"].append(f"--label-file {params['label_file']}") if params["log_opt"]: - for k, v in params['log_opt'].items(): - params["podman_args"].append(f"--log-opt {k.replace('max_size', 'max-size')}={v}") + params["log_opt"] = ["%s=%s" % (k.replace('max_size', 'max-size'), v) for k, v in params['log_opt'].items()] if params["mac_address"]: params["podman_args"].append(f"--mac-address {params['mac_address']}") if params["memory"]: diff --git a/tests/integration/targets/podman_container/tasks/main.yml b/tests/integration/targets/podman_container/tasks/main.yml index 17a5754d..3f939121 100644 --- a/tests/integration/targets/podman_container/tasks/main.yml +++ b/tests/integration/targets/podman_container/tasks/main.yml @@ -1233,6 +1233,10 @@ label: somelabel: labelvalue otheralbe: othervalue + log_opt: + max_size: 10mb + path: /var/log/container/mycontainer.json + tag: TestTag volumes: - /tmp:/data cgroups: no-conmon @@ -1291,6 +1295,9 @@ - "StopSignal=9" - "PodmanArgs=--cpus 0.5" - "PodmanArgs=--platform linux/amd64" + - "LogOpt=max-size=10mb" + - "LogOpt=path=/var/log/container/mycontainer.json" + - "LogOpt=tag=TestTag" loop_control: label: "{{ item }}" @@ -1344,6 +1351,10 @@ label: somelabel: labelvalue otheralbe: othervalue + log_opt: + max_size: 10mb + path: /var/log/container/mycontainer.json + tag: TestTag volumes: - /tmp:/data cgroups: no-conmon @@ -1407,6 +1418,10 @@ label: somelabel: labelvalue otheralbe: othervalue + log_opt: + max_size: 10mb + path: /var/log/container/mycontainer.json + tag: TestTag volumes: - /tmp:/data cgroups: no-conmon