mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Compare container images to Config.Image.
This commit is contained in:
parent
17334b21ea
commit
93b620ea8a
1 changed files with 12 additions and 6 deletions
|
@ -424,6 +424,13 @@ def get_split_image_tag(image):
|
||||||
|
|
||||||
return resource, tag
|
return resource, tag
|
||||||
|
|
||||||
|
def normalize_image(image):
|
||||||
|
"""
|
||||||
|
Normalize a Docker image name to include the implied :latest tag.
|
||||||
|
"""
|
||||||
|
|
||||||
|
return ":".join(get_split_image_tag(image))
|
||||||
|
|
||||||
|
|
||||||
def is_running(container):
|
def is_running(container):
|
||||||
'''Return True if an inspected container is in a state we consider "running."'''
|
'''Return True if an inspected container is in a state we consider "running."'''
|
||||||
|
@ -1113,11 +1120,13 @@ class DockerManager(object):
|
||||||
if inspected:
|
if inspected:
|
||||||
repo_tags = self.get_image_repo_tags()
|
repo_tags = self.get_image_repo_tags()
|
||||||
else:
|
else:
|
||||||
image, tag = get_split_image_tag(self.module.params.get('image'))
|
repo_tags = [normalize_image(self.module.params.get('image'))]
|
||||||
repo_tags = [':'.join([image, tag])]
|
|
||||||
|
|
||||||
for i in self.client.containers(all=True):
|
for i in self.client.containers(all=True):
|
||||||
running_image = i['Image']
|
details = self.client.inspect_container(i['Id'])
|
||||||
|
details = _docker_id_quirk(details)
|
||||||
|
|
||||||
|
running_image = normalize_image(details['Config']['Image'])
|
||||||
running_command = i['Command'].strip()
|
running_command = i['Command'].strip()
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
|
@ -1132,9 +1141,6 @@ class DockerManager(object):
|
||||||
matches = image_matches and command_matches
|
matches = image_matches and command_matches
|
||||||
|
|
||||||
if matches:
|
if matches:
|
||||||
details = self.client.inspect_container(i['Id'])
|
|
||||||
details = _docker_id_quirk(details)
|
|
||||||
|
|
||||||
deployed.append(details)
|
deployed.append(details)
|
||||||
|
|
||||||
return deployed
|
return deployed
|
||||||
|
|
Loading…
Reference in a new issue