mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix docker_container stop/start image dependency (#41678)
This commit adds a conditional inside the constructor so that if a user didn't specified an image parameter all the code related to the image version comparison is omitted. This is extremely useful when a user want to just stop and start containers using just the name, keeping everything as it is, without the need of specifying all the image and command stuff used at creation. Today if you don't specify the image you get an error, and this is a confusing [1] behavior. [1] https://github.com/ansible/ansible/issues/27960
This commit is contained in:
parent
0f6488bb15
commit
86387df8b3
1 changed files with 27 additions and 23 deletions
|
@ -1739,6 +1739,10 @@ class ContainerManager(DockerBaseClass):
|
||||||
|
|
||||||
def present(self, state):
|
def present(self, state):
|
||||||
container = self._get_container(self.parameters.name)
|
container = self._get_container(self.parameters.name)
|
||||||
|
|
||||||
|
# If the image parameter was passed then we need to deal with the image
|
||||||
|
# version comparison, otherwise we should not care
|
||||||
|
if self.parameters.image:
|
||||||
image = self._get_image()
|
image = self._get_image()
|
||||||
self.log(image, pretty_print=True)
|
self.log(image, pretty_print=True)
|
||||||
if not container.exists:
|
if not container.exists:
|
||||||
|
|
Loading…
Reference in a new issue