Improve container management tasks.
This commit is contained in:
parent
ae0c26b117
commit
245c08c125
1 changed files with 11 additions and 16 deletions
|
@ -10,19 +10,10 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
- name: stop all containers
|
- name: stop all containers
|
||||||
command: machinectl stop {{ contname }}{{ "%02d" | format(item|int) }}
|
systemd:
|
||||||
register: stop_cont
|
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
|
||||||
loop: "{{ containers | reverse}}"
|
state: stopped
|
||||||
tags:
|
loop: "{{ containers | reverse }}"
|
||||||
- never
|
|
||||||
- stop
|
|
||||||
- reset
|
|
||||||
- purge
|
|
||||||
|
|
||||||
- name: wait for containers to shut down
|
|
||||||
pause:
|
|
||||||
seconds: 30
|
|
||||||
when: stop_cont.changed | default(false)
|
|
||||||
tags:
|
tags:
|
||||||
- never
|
- never
|
||||||
- stop
|
- stop
|
||||||
|
@ -30,13 +21,15 @@
|
||||||
- purge
|
- purge
|
||||||
|
|
||||||
- name: purge all containers
|
- 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 }}"
|
loop: "{{ containers | reverse }}"
|
||||||
tags:
|
tags:
|
||||||
- never
|
- never
|
||||||
- purge
|
- purge
|
||||||
|
|
||||||
- name: reset all containers to the template
|
- name: remove container overlay
|
||||||
file:
|
file:
|
||||||
path: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}-delta
|
path: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}-delta
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -47,7 +40,9 @@
|
||||||
- purge
|
- purge
|
||||||
|
|
||||||
- name: start all containers
|
- 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 }}"
|
loop: "{{ containers | reverse }}"
|
||||||
tags:
|
tags:
|
||||||
- never
|
- never
|
||||||
|
|
Loading…
Add table
Reference in a new issue