Michal Nasiadka c4a1dcd3c7 Adapt code in preparation for ansible-lint bump
Rename True/False to true/false
Fix permissions values

Change-Id: I75be15fd24aeedf54bb22b9744bc0ee498a62645
2024-10-09 11:27:12 +02:00

49 lines
1.4 KiB
YAML

---
# Upgrading podman engine may cause containers to stop. Take a snapshot of the
# running containers prior to a potential upgrade of Podman.
- name: Check which containers are running
command: podman ps -f 'status=running' -q
become: true
# If Podman is not installed this command may exit non-zero.
failed_when: false
changed_when: false
register: running_containers
- name: Install packages
package:
name: "{{ podman_packages | select | list }}"
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
update_cache: true
state: present
become: true
register: podman_install_result
# If any packages were updated, and any containers were running, wait for the
# daemon to come up and start all previously running containers.
- name: Start podman.socket
become: true
service:
name: podman.socket
state: started
enabled: true
- block:
- name: Wait for Podman to start
command: podman info
become: true
changed_when: false
register: result
until: result is success
retries: 6
delay: 10
- name: Ensure containers are running after Podman upgrade
command: "podman start {{ running_containers.stdout }}"
become: true
changed_when: true
when:
- podman_install_result.changed
- running_containers.rc == 0
- running_containers.stdout != ''