- Update pruning options to include filters for containers, images, networks, and volumes. - Modify handlers to restart Podman resources based on new conditions. - Expand Molecule tests to verify networks, volumes, pods, and containers. - Adjust service management tasks for Podman services and auto-update. - Refactor tasks for better clarity and maintainability.
85 lines
2.5 KiB
YAML
85 lines
2.5 KiB
YAML
---
|
|
# handlers file for podman
|
|
|
|
- name: Restart podman
|
|
ansible.builtin.systemd:
|
|
name: podman
|
|
state: restarted
|
|
listen: restart podman
|
|
|
|
- name: Reload systemd
|
|
ansible.builtin.systemd:
|
|
daemon_reload: true
|
|
|
|
- name: Restart Podman networks
|
|
ansible.builtin.systemd:
|
|
name: "{{ item }}-network"
|
|
state: restarted
|
|
listen: Reload systemd
|
|
loop: "{{
|
|
(podman_networks | map(attribute='name') | list)
|
|
if (podman_use_quadlet | bool)
|
|
else (podman_network_output.results | selectattr('changed', 'equalto', true) | map(attribute='item.name') | list)
|
|
}}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when:
|
|
- podman_network_output is defined
|
|
- podman_network_output.results | length > 0
|
|
- not podman_generate_systemd | bool
|
|
|
|
- name: Restart Podman volumes
|
|
ansible.builtin.systemd:
|
|
name: "{{ item }}-volume"
|
|
state: restarted
|
|
listen: Reload systemd
|
|
loop: "{{
|
|
(podman_volumes | map(attribute='name') | list)
|
|
if (podman_use_quadlet | bool)
|
|
else (podman_volume_output.results | selectattr('changed', 'equalto', true) | map(attribute='item.name') | list)
|
|
}}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when:
|
|
- podman_volume_output is defined
|
|
- podman_volume_output.results | length > 0
|
|
- not podman_generate_systemd | bool
|
|
|
|
- name: Restart Podman pods
|
|
ansible.builtin.systemd:
|
|
name: >-
|
|
{{ (podman_systemd_options.pod_prefix if podman_generate_systemd | bool else '')
|
|
~ item ~ ('-pod' if not podman_generate_systemd | bool else '') }}
|
|
state: restarted
|
|
listen: Reload systemd
|
|
loop: "{{
|
|
(podman_pods | map(attribute='name') | list)
|
|
if (podman_use_quadlet | bool)
|
|
else (podman_pod_output.results | selectattr('changed', 'equalto', true) | map(attribute='item.name') | list)
|
|
}}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when:
|
|
- podman_pod_output is defined
|
|
- podman_pod_output.results | length > 0
|
|
|
|
- name: Restart changed Podman containers without pod assignment
|
|
ansible.builtin.systemd:
|
|
name: >-
|
|
{{ (podman_systemd_options.container_prefix
|
|
if podman_generate_systemd else '') + item }}
|
|
state: restarted
|
|
listen: Reload systemd
|
|
loop: >-
|
|
{{ (podman_container_output.results |
|
|
selectattr('changed', 'equalto', true) |
|
|
map(attribute='item.name') | list) |
|
|
intersect(podman_containers |
|
|
rejectattr('pod', 'defined') |
|
|
map(attribute='name') | list) }}
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when:
|
|
- podman_container_output is defined
|
|
- podman_container_output.results | length > 0
|