diff --git a/plugins/modules/podman_image.py b/plugins/modules/podman_image.py index 53b3ad3..96b98c3 100644 --- a/plugins/modules/podman_image.py +++ b/plugins/modules/podman_image.py @@ -542,7 +542,11 @@ class PodmanImageManager(object): rc, out, err = self._run(args, ignore_errors=True) if rc != 0: - self.module.fail_json(msg='Failed to pull image {image_name}'.format(image_name=image_name)) + if not self.pull: + self.module.fail_json(msg='Failed to find image {image_name} locally, image pull set to {pull_bool}'.format( + pull_bool=self.pull, image_name=image_name)) + else: + self.module.fail_json(msg='Failed to pull image {image_name}'.format(image_name=image_name)) return self.inspect_image(out.strip()) def build_image(self): diff --git a/tests/integration/targets/podman_image/tasks/main.yml b/tests/integration/targets/podman_image/tasks/main.yml index c5023f7..a19fc4c 100644 --- a/tests/integration/targets/podman_image/tasks/main.yml +++ b/tests/integration/targets/podman_image/tasks/main.yml @@ -179,6 +179,22 @@ - docker_build2 is not changed - "'localhost/dockerimage:latest' in dockerimage_info.images[0]['RepoTags'][0]" + - name: push image that doesn't exit to nowhere + containers.podman.podman_image: + name: bad_image + pull: false + push: yes + register: bad_push + ignore_errors: true + + - name: Ensure that Image failed correctly. + assert: + that: + - "bad_push is failed" + - "bad_push is not changed" + - "'Failed to find image bad_image' in bad_push.msg" + - "'image pull set to False' in bad_push.msg" + always: - name: Cleanup images containers.podman.podman_image: