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

Adding volume import and export option (#617)

* Adding volume import and export option

adding volume import and volume export to podman_import and podman_export
Updating integration tests

Signed-off-by: DilasserT <dilassert@gmail.com>

* Fixes and linting

Signed-off-by: DilasserT <dilassert@gmail.com>

---------

Signed-off-by: DilasserT <dilassert@gmail.com>
This commit is contained in:
DilasserT 2023-08-11 15:29:22 +02:00 committed by GitHub
parent aeec6b92d6
commit e4cd2c4493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 224 additions and 9 deletions

View file

@ -1,5 +1,5 @@
---
- name: Test podman export
- name: Test podman container export
block:
- name: Start container
containers.podman.podman_container:
@ -69,3 +69,83 @@
executable: "{{ test_executable | default('podman') }}"
name: container
state: absent
- name: Test podman volume export
block:
- name: Start container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container
image: alpine:3.7
state: started
volume:
- "volume:/test"
command: sleep 1d
- name: Export volume
containers.podman.podman_export:
executable: "{{ test_executable | default('podman') }}"
volume: volume
dest: /tmp/volume
- name: Check file
stat:
path: /tmp/volume
register: vlm
- name: Check it's exported
assert:
that:
- vlm.stat.exists
- name: Import volume
containers.podman.podman_import:
executable: "{{ test_executable | default('podman') }}"
src: /tmp/volume
volume: "volume"
register: volume
- name: Check it's imported
assert:
that:
- volume is success
- name: Export volume without force
containers.podman.podman_export:
executable: "{{ test_executable | default('podman') }}"
volume: volume
dest: /tmp/volume
force: false
register: volume2
- name: Check it's exported
assert:
that:
- volume2 is success
- volume2 is not changed
- name: Export volume with force
containers.podman.podman_export:
executable: "{{ test_executable | default('podman') }}"
volume: volume
dest: /tmp/volume
force: true
register: volume3
- name: Check it's not exported
assert:
that:
- volume3 is changed
always:
- name: Remove container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container
state: absent
- name: Remove volume
containers.podman.podman_volume:
executable: "{{ test_executable | default('podman') }}"
name: test_volume
state: absent

View file

@ -64,9 +64,86 @@
- test2.image.User == 'someuser'
- test2.image["Config"]["Cmd"][2] == "/bin/nonsh"
- name: Test podman volume import
block:
- name: Start container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container
image: alpine:3.7
state: started
volume:
- "volume:/test"
command: touch /test/test_file
- name: Export volume
containers.podman.podman_export:
executable: "{{ test_executable | default('podman') }}"
volume: volume
dest: /tmp/volume
- name: Check file
stat:
path: /tmp/volume
register: vlm
- name: Check it's exported
assert:
that:
- vlm.stat.exists
- name: delete container
containers.podman.podman_container:
state: absent
name: container
- name: delete volume
containers.podman.podman_volume:
state: absent
name: volume
# podman needs a volume to exist before import
- name: creating volume before importing
containers.podman.podman_volume:
name: volume
state: present
- name: Import volume
containers.podman.podman_import:
executable: "{{ test_executable | default('podman') }}"
src: /tmp/volume
volume: "volume"
register: volume
- name: Check it's imported
assert:
that:
- volume is success
- name: Check file is there
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container
image: alpine:3.7
state: started
volume:
- "volume:/test"
command: ls /test/test_file
register: ls
- name: Check it's imported
assert:
that:
- ls is success
always:
- name: Remove container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: container
state: absent
- name: Remove volume
containers.podman.podman_volume:
executable: "{{ test_executable | default('podman') }}"
name: volume
state: absent