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:
parent
132baa18e4
commit
8f5842dea6
2 changed files with 63 additions and 0 deletions
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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') }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue