mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Improve idempotency for devices mount of rootless podman (#487)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
parent
5f74d5b4fb
commit
bf67c7e078
2 changed files with 71 additions and 0 deletions
|
|
@ -855,7 +855,16 @@ class PodmanContainerDiff:
|
|||
def diffparam_device(self):
|
||||
before = [":".join([i['pathonhost'], i['pathincontainer']])
|
||||
for i in self.info['hostconfig']['devices']]
|
||||
if not before and 'createcommand' in self.info['config']:
|
||||
cr_com = self.info['config']['createcommand']
|
||||
if '--device' in cr_com:
|
||||
before = [cr_com[k + 1].lower()
|
||||
for k, i in enumerate(cr_com) if i == '--device']
|
||||
before = [":".join((i, i))
|
||||
if len(i.split(":")) == 1 else i for i in before]
|
||||
after = [":".join(i.split(":")[:2]) for i in self.params['device']]
|
||||
after = [":".join((i, i))
|
||||
if len(i.split(":")) == 1 else i for i in after]
|
||||
before, after = sorted(list(set(before))), sorted(list(set(after)))
|
||||
return self._diff_update_and_compare('devices', before, after)
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,68 @@
|
|||
tag: sometag
|
||||
command: 1h
|
||||
|
||||
- name: Run container with mounted /dev/fuse
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: started
|
||||
command: 1h
|
||||
device:
|
||||
- /dev/fuse
|
||||
register: test15
|
||||
|
||||
- name: Run container with mounted /dev/fuse again
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: started
|
||||
command: 1h
|
||||
device:
|
||||
- /dev/fuse
|
||||
register: test16
|
||||
|
||||
- name: Run container with mounted /dev/fuse:/dev/fuse
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: started
|
||||
command: 1h
|
||||
device:
|
||||
- /dev/fuse:/dev/fuse
|
||||
register: test17
|
||||
|
||||
- name: Run container with mounted /dev/fuse third time
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: started
|
||||
command: 1h
|
||||
device:
|
||||
- /dev/fuse
|
||||
register: test18
|
||||
|
||||
- name: Run container without mounted device
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: started
|
||||
command: 1h
|
||||
register: test19
|
||||
|
||||
- name: Check info with mounted devices
|
||||
assert:
|
||||
that:
|
||||
- test15 is changed
|
||||
- test16 is not changed
|
||||
- test17 is not changed
|
||||
- test18 is not changed
|
||||
- test19 is changed
|
||||
|
||||
- name: Remove test container
|
||||
containers.podman.podman_container:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue