Skip to content

Commit 1f2656f

Browse files
committed
cleanup podman pause process after build to allow container restart
1 parent 00fcc49 commit 1f2656f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ansible/cleanup.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,38 @@
2828
path: "/home/{{ ansible_user }}/.ssh/"
2929
state: absent
3030

31+
# A podman pause process is started by `podman pull`, and causes an error
32+
# Error: cannot re-exec process to join the existing user namespace
33+
# in podman commands in the booted image due to its pidfile.
34+
# Later podman versions may cleanup the pidfile automatically.
35+
# NB: This hard-codes the default config that only `podman` user (=1001) runs containers.
36+
- name: Check for running podman containers
37+
command:
38+
cmd: podman ps
39+
become_user: podman
40+
register: podman_ps
41+
changed_when: false
42+
43+
- name: Ensure no containers are running
44+
assert:
45+
that: podman_ps.stdout_lines | length == 1 # header only
46+
fail_msg: "podman user has running containers:\n{{ podman_ps.stdout }}"
47+
48+
- name: Get PID of podman pause process
49+
command:
50+
cmd: cat /tmp/podman-run-1001/libpod/tmp/pause.pid
51+
register: podman_pause_pidfile
52+
changed_when: false
53+
54+
- name: Kill pause process
55+
command:
56+
cmd: "kill {{ podman_pause_pidfile.stdout }}"
57+
become_user: podman
58+
59+
- name: Remove pause pidfile
60+
file:
61+
path: /tmp/podman-run-1001/libpod/tmp/pause.pid
62+
state: absent
63+
3164
- name: Run cloud-init cleanup
3265
command: cloud-init clean --logs --seed

0 commit comments

Comments
 (0)