1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-22 02:29:08 +00:00

Fix multi-image support for podman_save (#672)

Fix #670
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2023-11-26 21:31:47 +02:00 committed by GitHub
parent b7e8711230
commit 59a0dee373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 13 deletions

View file

@ -20,7 +20,8 @@ options:
image:
description:
- Image to save.
type: str
type: list
elements: str
required: true
compress:
description:
@ -70,9 +71,14 @@ RETURN = '''
EXAMPLES = '''
# What modules does for example
- containers.podman.podman_save:
dest: /path/to/tar/file
compress: true
format: oci-dir
image: nginx
dest: /tmp/file123.tar
- containers.podman.podman_save:
image:
- nginx
- fedora
dest: /tmp/file456.tar
multi_image_archive: true
'''
import os # noqa: E402
@ -92,7 +98,8 @@ def save(module, executable):
for param in module.params:
if module.params[param] is not None and param in cmd_args:
command += cmd_args[param]
command.append(module.params['image'])
for img in module.params['image']:
command.append(img)
if module.params['force']:
dest = module.params['dest']
if os.path.exists(dest):
@ -116,7 +123,7 @@ def save(module, executable):
def main():
module = AnsibleModule(
argument_spec=dict(
image=dict(type='str', required=True),
image=dict(type='list', elements='str', required=True),
compress=dict(type='bool'),
dest=dict(type='str', required=True, aliases=['path']),
format=dict(type='str', choices=['docker-archive', 'oci-archive', 'oci-dir', 'docker-dir']),