-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
roles/lxc_guest: improved syntax and upgrades
Debian version upgraded to buster. New templates compatibile with stable versions of LXC provided with debian. Cleaner syntax using `ssh_lxc.py` connection plugin. Now we don't user `lxc-attach -n ...` in the `shell` module on the host anymore, but we delegate to `{{ vm_name }}` with `connection: ssh_lxc`, using suitable Ansible module to do operation directly on the container before it is online and SSH accessible. We added an option to force an LVM VG name: if the default naming convention is not used the vg name can be overriden with the `vg_name` variable. The `xfs` filesystem seems to be broken in this release, so we used `ext4` as default for new container. This point needs further investigation.
- Loading branch information
Showing
6 changed files
with
60 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
auto_start: true | ||
container_state: started | ||
distro: stretch | ||
distro: buster | ||
vm_size: 5G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
auto lo | ||
iface lo inet loopback | ||
|
||
auto eth0 | ||
iface eth0 inet manual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
lxc.include = /usr/share/lxc/config/debian.common.conf | ||
|
||
lxc.utsname = {{ vm_name }} | ||
lxc.rootfs = /dev/{{ inventory_hostname }}vg/vm_{{ vm_name }} | ||
lxc.uts.name = {{ vm_name }} | ||
lxc.rootfs.path = lvm:/dev/{{ vg_name | default(inventory_hostname+'vg') }}/vm_{{ vm_name }} | ||
|
||
lxc.tty = 4 | ||
lxc.apparmor.profile = generated | ||
lxc.apparmor.allow_nesting = 1 | ||
|
||
lxc.tty.max = 4 | ||
lxc.arch = amd64 | ||
lxc.pty.max = 1024 | ||
|
||
lxc.network.type = veth | ||
lxc.network.flags = up | ||
lxc.network.link = br0 | ||
lxc.network.name = eth0 | ||
lxc.network.ipv4 = {{ hostvars | ip_from_inventory(vm_name) }}/24 | ||
lxc.network.ipv4.gateway = {{ hostvars | ip_from_inventory('vm_gateway') }} | ||
lxc.net.0.type = veth | ||
lxc.net.0.flags = up | ||
lxc.net.0.link = br0 | ||
lxc.net.0.name = eth0 | ||
lxc.net.0.ipv4.address = {{ hostvars | ip_from_inventory(vm_name) }}/24 | ||
lxc.net.0.ipv4.gateway = {{ hostvars | ip_from_inventory('vm_gateway') }} | ||
lxc.start.auto = {% if auto_start %}1{% else %}0{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
domain dmz.lilik.it | ||
nameserver {{ hostvars | ip_from_inventory('vm_gateway') }} |
An example of how we can easily use the native Ansible module on offline LXC container without building custom modules,