mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-05-05 23:15:45 +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:
parent
b7e8711230
commit
59a0dee373
2 changed files with 42 additions and 13 deletions
|
|
@ -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']),
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@
|
|||
- name: Pull image
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: k8s.gcr.io/pause
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- registry.k8s.io/pause
|
||||
- registry.k8s.io/coredns/coredns:v1.9.3
|
||||
|
||||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/image.tar
|
||||
|
||||
- name: Check file
|
||||
|
|
@ -23,7 +26,7 @@
|
|||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/image.tar
|
||||
force: true
|
||||
|
||||
|
|
@ -40,7 +43,7 @@
|
|||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/imagedir
|
||||
format: oci-dir
|
||||
|
||||
|
|
@ -57,7 +60,7 @@
|
|||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/imagedir-docker
|
||||
force: true
|
||||
format: docker-dir
|
||||
|
|
@ -66,7 +69,7 @@
|
|||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/imagedir
|
||||
force: true
|
||||
format: oci-dir
|
||||
|
|
@ -84,7 +87,7 @@
|
|||
- name: Save image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: k8s.gcr.io/pause
|
||||
image: registry.k8s.io/pause
|
||||
dest: /tmp/image2.tar
|
||||
multi_image_archive: true
|
||||
|
||||
|
|
@ -97,3 +100,22 @@
|
|||
assert:
|
||||
that:
|
||||
- img.stat.exists
|
||||
|
||||
- name: Save multi image
|
||||
containers.podman.podman_save:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image:
|
||||
- registry.k8s.io/pause
|
||||
- registry.k8s.io/coredns/coredns:v1.9.3
|
||||
dest: /tmp/image-multi.tar
|
||||
multi_image_archive: true
|
||||
|
||||
- name: Check mult image file
|
||||
stat:
|
||||
path: /tmp/image-multi.tar
|
||||
register: img
|
||||
|
||||
- name: Check multi image is saved
|
||||
assert:
|
||||
that:
|
||||
- img.stat.exists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue