1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Fix idempotency for volume GID and UID

Fix #150
Add special treat for volume GIDs and UIDs options.
This commit is contained in:
Sagi Shnaidman 2020-12-20 21:04:08 +02:00 committed by Sergey
parent 62638bac26
commit 075d35daee
2 changed files with 123 additions and 0 deletions

View file

@ -234,6 +234,18 @@ class PodmanVolumeDiff:
before = self.info['options'] if 'options' in self.info else {}
before = ["=".join((k, v)) for k, v in before.items()]
after = self.params['options']
# Gor UID, GID
ids = []
if self.info['uid']:
before += ['uid=%s' % str(self.info['uid'])]
if self.info['gid']:
before += ['gid=%s' % str(self.info['gid'])]
if self.params['options']:
for opt in self.params['options']:
if 'uid=' in opt or 'gid=' in opt:
ids += opt.split("o=")[1].split(",")
after = [i for i in after if 'gid' not in i and 'uid' not in i]
after += ids
before, after = sorted(list(set(before))), sorted(list(set(after)))
return self._diff_update_and_compare('options', before, after)

View file

@ -148,6 +148,117 @@
- info10 is failed
- delete.volume == {}
- name: Create volume with UID option
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=uid=1001"
register: info11
- name: Check info
assert:
that:
- info11 is changed
- name: Create volume with UID option - again
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=uid=1001"
register: info12
- name: Check info
assert:
that:
- info12 is not changed
- name: Create volume with UID option - default
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
register: info13
- name: Check info
assert:
that:
- info13 is changed
- name: Create volume with GID option
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=gid=1001"
register: info14
- name: Check info
assert:
that:
- info14 is changed
- name: Create volume with GID option - again
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=gid=1001"
register: info15
- name: Check info
assert:
that:
- info15 is not changed
- name: Create volume with GID option - default
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
register: info16
- name: Check info
assert:
that:
- info16 is changed
- name: Create volume with GID and UID option
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=gid=1002,uid=1002"
register: info17
- name: Check info
assert:
that:
- info17 is changed
- name: Create volume with GID and UID option - again
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
options:
- "o=uid=1002"
- "o=gid=1002"
register: info18
- name: Check info
assert:
that:
- info18 is not changed
- name: Create volume with GID and UID option - default
containers.podman.podman_volume:
name: "{{ volume_name }}"
state: present
register: info19
- name: Check info
assert:
that:
- info19 is changed
always:
- name: Make sure volume doesn't exist