Improve container management tasks.

This commit is contained in:
Andreas B. Mundt 2021-11-18 20:18:56 +01:00 committed by Andreas B. Mundt
parent ae0c26b117
commit 245c08c125

View file

@ -10,8 +10,9 @@
##
- name: stop all containers
command: machinectl stop {{ contname }}{{ "%02d" | format(item|int) }}
register: stop_cont
systemd:
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
state: stopped
loop: "{{ containers | reverse }}"
tags:
- never
@ -19,24 +20,16 @@
- reset
- purge
- name: wait for containers to shut down
pause:
seconds: 30
when: stop_cont.changed | default(false)
tags:
- never
- stop
- reset
- purge
- name: purge all containers
command: machinectl remove {{ contname }}{{ "%02d" | format(item|int) }}
command:
cmd: machinectl remove {{ contname }}{{ "%02d" | format(item|int) }}
removes: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}
loop: "{{ containers | reverse }}"
tags:
- never
- purge
- name: reset all containers to the template
- name: remove container overlay
file:
path: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}-delta
state: absent
@ -47,7 +40,9 @@
- purge
- name: start all containers
command: machinectl start {{ contname }}{{ "%02d" | format(item|int) }}
systemd:
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
state: started
loop: "{{ containers | reverse }}"
tags:
- never