Instead of cloning the image, link to the rootfs. Provide more individual files.
This commit is contained in:
parent
b920bdf52b
commit
fed5f71357
3 changed files with 20 additions and 7 deletions
|
@ -88,10 +88,11 @@
|
||||||
- { src: systemd-networkd.socket, dest: sockets.target.wants/systemd-networkd.socket }
|
- { src: systemd-networkd.socket, dest: sockets.target.wants/systemd-networkd.socket }
|
||||||
- { src: systemd-networkd-wait-online.service, dest: network-online.target.wants/systemd-networkd-wait-online.service }
|
- { src: systemd-networkd-wait-online.service, dest: network-online.target.wants/systemd-networkd-wait-online.service }
|
||||||
|
|
||||||
- name: clone the initial container
|
- name: generate links to the initial container
|
||||||
command: machinectl clone {{ contname }}00 {{ contname }}{{ "%02d" | format(item|int) }}
|
file:
|
||||||
args:
|
src: "{{ contname }}00"
|
||||||
creates: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}
|
dest: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}
|
||||||
|
state: link
|
||||||
loop: "{{ containers[1:] }}"
|
loop: "{{ containers[1:] }}"
|
||||||
|
|
||||||
- name: provide container configuration
|
- name: provide container configuration
|
||||||
|
@ -100,15 +101,21 @@
|
||||||
dest: /etc/systemd/nspawn/{{ contname}}{{ "%02d" | format(item|int) }}.nspawn
|
dest: /etc/systemd/nspawn/{{ contname}}{{ "%02d" | format(item|int) }}.nspawn
|
||||||
loop: "{{ containers }}"
|
loop: "{{ containers }}"
|
||||||
|
|
||||||
- name: provide container hostname
|
- name: provide container hostname file
|
||||||
template:
|
template:
|
||||||
src: hostname.j2
|
src: hostname.j2
|
||||||
dest: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}/etc/hostname
|
dest: /var/lib/machines/{{ contname }}{{ "%02d" | format(item|int) }}.hostname
|
||||||
|
loop: "{{ containers }}"
|
||||||
|
|
||||||
|
- name: provide container hosts file
|
||||||
|
template:
|
||||||
|
src: hosts.j2
|
||||||
|
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
|
||||||
systemd:
|
systemd:
|
||||||
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
|
name: systemd-nspawn@{{ contname }}{{ "%02d" | format(item|int) }}.service
|
||||||
state: started
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
loop: "{{ containers }}"
|
loop: "{{ containers }}"
|
||||||
|
|
|
@ -9,3 +9,5 @@ Port=10{{ "%03d" | format(item|int + 100) }}:80
|
||||||
[Files]
|
[Files]
|
||||||
Volatile=overlay
|
Volatile=overlay
|
||||||
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) }}.hosts:/etc/hosts
|
||||||
|
|
4
roles/educontainer/templates/hosts.j2
Normal file
4
roles/educontainer/templates/hosts.j2
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
127.0.0.1 localhost {{ contname }}{{ "%02d" | format(item|int) }}
|
||||||
|
::1 localhost {{ contname }}{{ "%02d" | format(item|int) }} ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
Loading…
Add table
Reference in a new issue