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.
When creating a single container and a pod on the same host, both
container_image
andcontainer_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
andcontainer_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 excludeimage_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.