1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-22 02:29:08 +00:00

Add diff and change detection to systemd generation (#608)

Fix #339
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2023-08-03 16:26:18 +03:00 committed by GitHub
parent cc34c2b780
commit 7a307453a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 203 additions and 28 deletions

View file

@ -0,0 +1,123 @@
# Systemd generation
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: idempotency
state: absent
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: started
command: 1h
generate_systemd:
path: /tmp/
restart_policy: always
time: 120
no_header: true
names: true
pod_prefix: whocares
separator: zzzz
container_prefix: contain
register: system0
- name: Check if the result is changed
assert:
that:
- system0 is changed
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: started
command: 1h
generate_systemd:
path: /tmp/
restart_policy: always
time: 120
no_header: true
names: true
pod_prefix: whocares
separator: zzzz
container_prefix: contain
register: system1
- name: Check if the result is not changed
assert:
that:
- system1 is not changed
- name: Remove the systemd unit file
ansible.builtin.file:
path: /tmp/containzzzzidempotency.service
state: absent
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: started
command: 1h
generate_systemd:
path: /tmp/
restart_policy: always
time: 120
no_header: true
names: true
pod_prefix: whocares
separator: zzzz
container_prefix: contain
register: system2
- name: Check if the result is changed
assert:
that:
- system2 is changed
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: started
command: 1h
generate_systemd:
path: /tmp/
restart_policy: always
time: 120
no_header: true
names: true
pod_prefix: whocares
separator: zzzz
container_prefix: contain
register: system3
- name: Check if the result is not changed
assert:
that:
- system3 is not changed
- name: Add string to change the systemd unit file
ansible.builtin.shell: echo 'test=onetwo' >> /tmp/containzzzzidempotency.service
- containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
image: "{{ idem_image }}"
name: idempotency
state: started
command: 1h
generate_systemd:
path: /tmp/
restart_policy: always
time: 120
no_header: true
names: true
pod_prefix: whocares
separator: zzzz
container_prefix: contain
register: system4
- name: Check if the result is changed
assert:
that:
- system4 is changed

View file

@ -23,6 +23,9 @@
- name: Test idempotency of containers in pods
include_tasks: idem_pods.yml
- name: Test idempotency of systemd generation
include_tasks: idem_systemd.yml
- name: Test idempotency of other settings
include_tasks: idem_all.yml