1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Fix podman load module for Podman 4 (#503)

Fix #486
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2022-10-31 16:23:35 -04:00 committed by GitHub
parent 712c3230b2
commit 9e92a6e90c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -155,7 +155,14 @@ def load(module, executable):
if rc != 0:
module.fail_json(msg="Image loading failed: %s" % (err))
image_name_line = [i for i in out.splitlines() if 'Loaded image' in i][0]
image_name = image_name_line.split("Loaded image(s): ")[1].split(',')[0].strip()
# For Podman < 4.x
if 'Loaded image(s):' in image_name_line:
image_name = image_name_line.split("Loaded image(s): ")[1].split(',')[0].strip()
# For Podman > 4.x
elif 'Loaded image:' in image_name_line:
image_name = image_name_line.split("Loaded image: ")[1].strip()
else:
module.fail_json(msg="Not found images in %s" % image_name_line)
rc, out2, err2 = module.run_command([executable, 'image', 'inspect', image_name])
if rc != 0:
module.fail_json(msg="Image %s inspection failed: %s" % (image_name, err2))