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

Add idempotency for restart-policy for containers (#548)

Fix: #440

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2023-02-12 13:00:00 +02:00 committed by GitHub
parent 132baa18e4
commit 8f5842dea6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 0 deletions

View file

@ -1163,6 +1163,11 @@ class PodmanContainerDiff:
after = self.params['read_only']
return self._diff_update_and_compare('read_only', before, after)
def diffparam_restart_policy(self):
before = self.info['hostconfig']['restartpolicy']['name']
after = self.params['restart_policy'] or ""
return self._diff_update_and_compare('restart_policy', before, after)
def diffparam_rm(self):
before = self.info['hostconfig']['autoremove']
after = self.params['rm']

View file

@ -274,6 +274,64 @@
assert:
that: test21 is not changed
- name: Run default container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: present
- name: Run container with restart policy always
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: present
restart_policy: always
register: test22
- name: Check info with restart policy always
assert:
that: test22 is changed
- name: Run container with restart policy always again
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: present
restart_policy: always
register: test23
- name: Check info with restart policy always again
assert:
that: test23 is not changed
- name: Run container with a different restart policy on-failure
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: present
restart_policy: on-failure
register: test24
- name: Check info with restart policy on-failure
assert:
that: test24 is changed
- name: Run default container w/o restart policy
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: present
register: test25
- name: Check info w/o restart policy
assert:
that: test25 is changed
- name: Remove test container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"