Change-Id: Idfbcfa8e9fc157c691ea30ebc5b6235ac4c3b436 Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
---
|
|
- name: Check for leftover containers
|
|
ansible.builtin.command:
|
|
cmd: podman ps -q
|
|
become: true
|
|
changed_when: false
|
|
failed_when: false
|
|
register: containers
|
|
|
|
- name: Check for leftover volumes
|
|
ansible.builtin.command:
|
|
cmd: podman volume ls -q
|
|
become: true
|
|
changed_when: false
|
|
failed_when: false
|
|
register: volumes
|
|
|
|
- name: Fail if there are any containers
|
|
ansible.builtin.assert:
|
|
that: (containers.stdout_lines | length) == 0
|
|
fail_msg: |-
|
|
There are still some containers left over!
|
|
Remove them before uninstalling container engine!
|
|
|
|
- name: Fail if there are any volumes
|
|
ansible.builtin.assert:
|
|
that: (volumes.stdout_lines | length) == 0
|
|
fail_msg: |-
|
|
There are still some volumes left over!
|
|
Remove them before uninstalling container engine!
|
|
|
|
- name: Uninstall podman packages
|
|
become: true
|
|
ansible.builtin.package:
|
|
name: "{{ podman_packages | select | list }}"
|
|
autoclean: true
|
|
state: absent
|
|
|
|
- block:
|
|
# NOTE(mhiner): cleanup is best effort because sometimes there are still
|
|
# qemu-kvm processes running that prevent the removal
|
|
- name: Cleanup docker files
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop: "{{ podman_paths }}"
|
|
rescue:
|
|
- name: Unable to remove all files
|
|
ansible.builtin.debug:
|
|
var: ansible_failed_result
|