|
|
@ -250,7 +250,9 @@ image:
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.docker_common import HAS_DOCKER_PY_2, HAS_DOCKER_PY_3, AnsibleDockerClient, DockerBaseClass
|
|
|
|
from ansible.module_utils.docker_common import (
|
|
|
|
|
|
|
|
HAS_DOCKER_PY_2, HAS_DOCKER_PY_3, AnsibleDockerClient, DockerBaseClass, is_image_name_id,
|
|
|
|
|
|
|
|
)
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -293,10 +295,11 @@ class ImageManager(DockerBaseClass):
|
|
|
|
self.buildargs = parameters.get('buildargs')
|
|
|
|
self.buildargs = parameters.get('buildargs')
|
|
|
|
|
|
|
|
|
|
|
|
# If name contains a tag, it takes precedence over tag parameter.
|
|
|
|
# If name contains a tag, it takes precedence over tag parameter.
|
|
|
|
repo, repo_tag = parse_repository_tag(self.name)
|
|
|
|
if not is_image_name_id(self.name):
|
|
|
|
if repo_tag:
|
|
|
|
repo, repo_tag = parse_repository_tag(self.name)
|
|
|
|
self.name = repo
|
|
|
|
if repo_tag:
|
|
|
|
self.tag = repo_tag
|
|
|
|
self.name = repo
|
|
|
|
|
|
|
|
self.tag = repo_tag
|
|
|
|
|
|
|
|
|
|
|
|
if self.state in ['present', 'build']:
|
|
|
|
if self.state in ['present', 'build']:
|
|
|
|
self.present()
|
|
|
|
self.present()
|
|
|
@ -363,11 +366,14 @@ class ImageManager(DockerBaseClass):
|
|
|
|
|
|
|
|
|
|
|
|
:return None
|
|
|
|
:return None
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
image = self.client.find_image(self.name, self.tag)
|
|
|
|
name = self.name
|
|
|
|
if image:
|
|
|
|
if is_image_name_id(name):
|
|
|
|
name = self.name
|
|
|
|
image = self.client.find_image_by_id(name)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
image = self.client.find_image(name, self.tag)
|
|
|
|
if self.tag:
|
|
|
|
if self.tag:
|
|
|
|
name = "%s:%s" % (self.name, self.tag)
|
|
|
|
name = "%s:%s" % (self.name, self.tag)
|
|
|
|
|
|
|
|
if image:
|
|
|
|
if not self.check_mode:
|
|
|
|
if not self.check_mode:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.client.remove_image(name, force=self.force)
|
|
|
|
self.client.remove_image(name, force=self.force)
|
|
|
|