ikke-t / podman-container-systemd

creates systemd files and creates containers using podman
118 stars 44 forks source link

Unintended behaviour when using this role multiple times to define a single container and a pod. #22

Closed lberezy closed 3 years ago

lberezy commented 4 years ago

When creating a single container and a pod on the same host, both container_image and container_image_list will be defined, leading to unintended behaviour. For example, when the pod is created before the simple container, two unit files will be created for the container (one for a container and another as if it were a pod), resulting in an error when starting the service.

I believe that this issue stems from container_image and container_image_list variables not being mutually exclusive and the tasks checking if these variables have been defined. As Ansible does not (yet) support a way of un-defining a variable, there's no easy workaround to clear these variables when they are applied on the same host.

I propose modifying the when clauses to (for example) when: container_image_list | length > 0, perhaps with some other logic to mutually exclude image_list. This would at-least allow users to set these variables to an empty value as a workaround.

Alternatively, standardise on using only container_image_list and explicitly testing for cases where it has 1 item or more than 1 item when deciding to set up a single container or a pod, respectively. This provides an implicit mutual exclusion between these two cases, but may be considered a breaking change.

ikke-t commented 4 years ago

Thanks, I like the idea. I was thinking the same at some point, but just got lazy.