Make IP address assignment work with libvirt
The systemd-networkd script in vmdebootstrap that is used to build the Debian libvirt vagrant boxes is a bit too eager assigning DHCP to network interfaces. This patch changes the network script to only take care of the primary network interface (first non loopback).
This commit is contained in:
parent
9f662e3afb
commit
a98f6e54e7
2 changed files with 18 additions and 1 deletions
4
Vagrantfile
vendored
4
Vagrantfile
vendored
|
@ -5,7 +5,7 @@ Vagrant.configure(2) do |config|
|
||||||
config.vm.box = "debian/buster64"
|
config.vm.box = "debian/buster64"
|
||||||
|
|
||||||
config.vm.hostname = "gvaldap.local"
|
config.vm.hostname = "gvaldap.local"
|
||||||
config.vm.network "private_network", ip: "172.16.3.3", lxc__bridge_name: 'vlxcbr1'
|
config.vm.network :private_network, :ip => "172.16.3.3"
|
||||||
|
|
||||||
config.vm.network "forwarded_port", guest: 8000, host: 8001
|
config.vm.network "forwarded_port", guest: 8000, host: 8001
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ Vagrant.configure(2) do |config|
|
||||||
libvirt.memory = 1024
|
libvirt.memory = 1024
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.vm.provision :shell, path: "change-vmdebootstrap-default-dhcp.sh"
|
||||||
|
|
||||||
config.vm.provision :salt do |salt|
|
config.vm.provision :salt do |salt|
|
||||||
salt.bootstrap_options = "-x python3"
|
salt.bootstrap_options = "-x python3"
|
||||||
salt.minion_id = "gvaldap"
|
salt.minion_id = "gvaldap"
|
||||||
|
|
15
change-vmdebootstrap-default-dhcp.sh
Normal file
15
change-vmdebootstrap-default-dhcp.sh
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
debootstrap_network=/etc/systemd/network/99-dhcp.network
|
||||||
|
|
||||||
|
if grep -q '^Name=\\*' "${debootstrap_network}"; then
|
||||||
|
primary_nic=$(ls -1 /sys/class/net | grep -v lo |sort | head -1)
|
||||||
|
sed -i "s/^Name=e\\*/Name=${primary_nic})/" \
|
||||||
|
"${debootstrap_network}"
|
||||||
|
systemctl restart systemd-networkd.service
|
||||||
|
echo "Changed systemd network configuration"
|
||||||
|
else
|
||||||
|
echo "Systemd network configuration has already been changed"
|
||||||
|
fi
|
Loading…
Reference in a new issue