Skip to content

Commit 6ff93e7

Browse files
podman_container_lib: Added checks for volume opts (#941)
* podman_container_lib: Added checks for volume opts Changed the diffparam_volume function to include the volume mount opts. Signed-off-by: Lucas Benedito <[email protected]> * Add test for volume mount options Signed-off-by: Lucas Benedito <[email protected]> --------- Signed-off-by: Lucas Benedito <[email protected]>
1 parent 4c682e1 commit 6ff93e7

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

plugins/module_utils/podman/podman_container_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,12 +1560,12 @@ def clean_volume(x):
15601560
after = self.params["volume"]
15611561
if after is not None:
15621562
after = [
1563-
":".join([clean_volume(i) for i in v.split(":")[:2]])
1563+
":".join([clean_volume(i) for i in v.split(":")[:3]])
15641564
for v in self.params["volume"]
15651565
]
15661566
if before is not None:
15671567
before = [
1568-
":".join([clean_volume(i) for i in v.split(":")[:2]]) for v in before
1568+
":".join([clean_volume(i) for i in v.split(":")[:3]]) for v in before
15691569
]
15701570
if before is None and after is None:
15711571
return self._diff_update_and_compare("volume", before, after)

tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,36 @@
349349
- name: check test23
350350
assert:
351351
that: test23 is not changed
352+
353+
- ansible.builtin.file:
354+
path: /tmp/data
355+
state: directory
356+
357+
- containers.podman.podman_container:
358+
executable: "{{ test_executable | default('podman') }}"
359+
name: test24
360+
image: alpine
361+
state: present
362+
volumes:
363+
- /tmp/data:/data:z
364+
365+
- containers.podman.podman_container:
366+
executable: "{{ test_executable | default('podman') }}"
367+
name: test24
368+
image: alpine
369+
state: present
370+
volumes:
371+
- /tmp/data:/data:U
372+
register: test24
373+
374+
- name: Check test24
375+
assert:
376+
that:
377+
- test24 is changed
378+
- >-
379+
(test24.container['Config']['CreateCommand'] is defined and
380+
'/tmp/data:/data:U' in test24.container['Config']['CreateCommand'] | list)
381+
382+
- ansible.builtin.file:
383+
path: /tmp/data
384+
state: absent

0 commit comments

Comments
 (0)