mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-03-22 02:29:08 +00:00
Fix pulling short image name (#614)
Also return image data when pulling it. Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
7a307453a5
commit
b91ddd3db7
2 changed files with 29 additions and 8 deletions
|
|
@ -512,6 +512,8 @@ class PodmanImageManager(object):
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
self.results['image'], output = self.push_image()
|
self.results['image'], output = self.push_image()
|
||||||
self.results['stdout'] += "\n" + output
|
self.results['stdout'] += "\n" + output
|
||||||
|
if image and not self.results.get('image'):
|
||||||
|
self.results['image'] = image
|
||||||
|
|
||||||
def absent(self):
|
def absent(self):
|
||||||
image = self.find_image()
|
image = self.find_image()
|
||||||
|
|
@ -537,11 +539,17 @@ class PodmanImageManager(object):
|
||||||
args = ['image', 'ls', image_name, '--format', 'json']
|
args = ['image', 'ls', image_name, '--format', 'json']
|
||||||
rc, images, err = self._run(args, ignore_errors=True)
|
rc, images, err = self._run(args, ignore_errors=True)
|
||||||
images = json.loads(images)
|
images = json.loads(images)
|
||||||
|
if len(images) == 0:
|
||||||
|
# Let's find out if image exists
|
||||||
|
rc, out, err = self._run(['image', 'exists', image_name], ignore_errors=True)
|
||||||
|
if rc == 0:
|
||||||
|
inspect_json = self.inspect_image(image_name)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
if len(images) > 0:
|
if len(images) > 0:
|
||||||
inspect_json = self.inspect_image(image_name)
|
inspect_json = self.inspect_image(image_name)
|
||||||
if self._is_target_arch(inspect_json, self.arch) or not self.arch:
|
if self._is_target_arch(inspect_json, self.arch) or not self.arch:
|
||||||
return images
|
return images or inspect_json
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _is_target_arch(self, inspect_json=None, arch=None):
|
def _is_target_arch(self, inspect_json=None, arch=None):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
- name: Test podman_image
|
- name: Test podman_image
|
||||||
block:
|
block:
|
||||||
|
- name: List all images on host before test
|
||||||
|
containers.podman.podman_image_info:
|
||||||
|
|
||||||
|
- name: Remove images for test
|
||||||
|
containers.podman.podman_image:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- quay.io/coreos/alpine-sh
|
||||||
|
- docker.io/alpine
|
||||||
|
- docker.io/library/ubuntu
|
||||||
|
- docker.io/library/alpine
|
||||||
|
|
||||||
- name: Pull image
|
- name: Pull image
|
||||||
containers.podman.podman_image:
|
containers.podman.podman_image:
|
||||||
executable: "{{ test_executable | default('podman') }}"
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
|
|
@ -47,7 +60,7 @@
|
||||||
- pull1.podman_actions is defined
|
- pull1.podman_actions is defined
|
||||||
- pull2 is not changed
|
- pull2 is not changed
|
||||||
- pull3 is changed
|
- pull3 is changed
|
||||||
- pull4 is changed
|
- pull4 is not changed
|
||||||
- pull5 is not changed
|
- pull5 is not changed
|
||||||
- pull6 is changed
|
- pull6 is changed
|
||||||
- "'alpine-sh' in images.stdout"
|
- "'alpine-sh' in images.stdout"
|
||||||
|
|
@ -83,14 +96,14 @@
|
||||||
state: absent
|
state: absent
|
||||||
register: rmi3
|
register: rmi3
|
||||||
|
|
||||||
- name: Try to remove docker.io image using short url
|
- name: Remove docker.io image using short url
|
||||||
containers.podman.podman_image:
|
containers.podman.podman_image:
|
||||||
executable: "{{ test_executable | default('podman') }}"
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
name: docker.io/alpine
|
name: docker.io/alpine
|
||||||
state: absent
|
state: absent
|
||||||
register: rmi4
|
register: rmi4
|
||||||
|
|
||||||
- name: Remove docker.io image using normalised url
|
- name: Try to remove docker.io image using normalised url
|
||||||
containers.podman.podman_image:
|
containers.podman.podman_image:
|
||||||
executable: "{{ test_executable | default('podman') }}"
|
executable: "{{ test_executable | default('podman') }}"
|
||||||
name: docker.io/library/alpine
|
name: docker.io/library/alpine
|
||||||
|
|
@ -121,8 +134,8 @@
|
||||||
- rmi1 is changed
|
- rmi1 is changed
|
||||||
- rmi2 is not changed
|
- rmi2 is not changed
|
||||||
- rmi3 is changed
|
- rmi3 is changed
|
||||||
- rmi4 is not changed
|
- rmi4 is changed
|
||||||
- rmi5 is changed
|
- rmi5 is not changed
|
||||||
- rmi6 is changed
|
- rmi6 is changed
|
||||||
- "'alpine-sh' not in images.stdout"
|
- "'alpine-sh' not in images.stdout"
|
||||||
- "'library/ubuntu' not in images.stdout"
|
- "'library/ubuntu' not in images.stdout"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue