Switch to persistent overlays.
With tmpfs the containers' disk space is too limited. Better keep changes on the disk.
This commit is contained in:
parent
fed5f71357
commit
7bbfd817f8
2 changed files with 27 additions and 11 deletions
|
@ -9,19 +9,14 @@
|
||||||
## User 'ansible' in the sudo group. Password is empty.
|
## User 'ansible' in the sudo group. Password is empty.
|
||||||
##
|
##
|
||||||
|
|
||||||
- name: start all containers
|
|
||||||
command: machinectl start {{ contname }}{{ "%02d" | format(item|int) }}
|
|
||||||
loop: "{{ containers }}"
|
|
||||||
tags:
|
|
||||||
- never
|
|
||||||
- start
|
|
||||||
|
|
||||||
- name: stop all containers
|
- name: stop all containers
|
||||||
command: machinectl stop {{ contname }}{{ "%02d" | format(item|int) }}
|
command: machinectl stop {{ contname }}{{ "%02d" | format(item|int) }}
|
||||||
loop: "{{ containers }}"
|
loop: "{{ containers }}"
|
||||||
tags:
|
tags:
|
||||||
- never
|
- never
|
||||||
- stop
|
- stop
|
||||||
|
- reset
|
||||||
|
- purge
|
||||||
|
|
||||||
- name: purge all containers
|
- name: purge all containers
|
||||||
command: machinectl remove {{ contname }}{{ "%02d" | format(item|int) }}
|
command: machinectl remove {{ contname }}{{ "%02d" | format(item|int) }}
|
||||||
|
@ -30,12 +25,31 @@
|
||||||
- never
|
- never
|
||||||
- purge
|
- purge
|
||||||
|
|
||||||
|
- name: reset all containers to the template
|
||||||
|
file:
|
||||||
|
path: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}-delta
|
||||||
|
state: absent
|
||||||
|
loop: "{{ containers }}"
|
||||||
|
tags:
|
||||||
|
- never
|
||||||
|
- reset
|
||||||
|
|
||||||
|
- name: start all containers
|
||||||
|
command: machinectl start {{ contname }}{{ "%02d" | format(item|int) }}
|
||||||
|
loop: "{{ containers }}"
|
||||||
|
tags:
|
||||||
|
- never
|
||||||
|
- start
|
||||||
|
- reset
|
||||||
|
|
||||||
|
###########
|
||||||
|
|
||||||
- name: debootstrap minimal system
|
- name: debootstrap minimal system
|
||||||
command:
|
command:
|
||||||
cmd: >
|
cmd: >
|
||||||
debootstrap
|
debootstrap
|
||||||
--include=systemd-{{ contname }}ainer,openssh-server,sudo
|
--include=systemd-container,openssh-server,sudo,python3
|
||||||
--components=main,{{ contname }}rib,non-free stable
|
--components=main,contrib,non-free stable
|
||||||
{{ contname }}00 http://deb.debian.org/debian
|
{{ contname }}00 http://deb.debian.org/debian
|
||||||
args:
|
args:
|
||||||
chdir: /var/lib/machines/
|
chdir: /var/lib/machines/
|
||||||
|
@ -113,7 +127,7 @@
|
||||||
dest: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hosts
|
dest: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hosts
|
||||||
loop: "{{ containers }}"
|
loop: "{{ containers }}"
|
||||||
|
|
||||||
- name: start all containers on boot
|
- name: start all containers on boot and restart now
|
||||||
systemd:
|
systemd:
|
||||||
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
|
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -5,9 +5,11 @@ ResolvConf=copy-host
|
||||||
[Network]
|
[Network]
|
||||||
Port=10{{ "%03d" | format(item|int) }}:22
|
Port=10{{ "%03d" | format(item|int) }}:22
|
||||||
Port=10{{ "%03d" | format(item|int + 100) }}:80
|
Port=10{{ "%03d" | format(item|int + 100) }}:80
|
||||||
|
Port=10{{ "%03d" | format(item|int + 200) }}:443
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
Volatile=overlay
|
ReadOnly=yes
|
||||||
|
Overlay=+/:/var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}-delta:/
|
||||||
PrivateUsersChown=false
|
PrivateUsersChown=false
|
||||||
BindReadOnly=/var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hostname:/etc/hostname
|
BindReadOnly=/var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hostname:/etc/hostname
|
||||||
BindReadOnly=/var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hosts:/etc/hosts
|
BindReadOnly=/var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hosts:/etc/hosts
|
||||||
|
|
Loading…
Add table
Reference in a new issue