Browse Source

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).
master
Jan Dittberner 2 years ago
parent
commit
a98f6e54e7
  1. 4
      Vagrantfile
  2. 15
      change-vmdebootstrap-default-dhcp.sh

4
Vagrantfile

@ -5,7 +5,7 @@ Vagrant.configure(2) do |config|
config.vm.box = "debian/buster64"
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
@ -16,6 +16,8 @@ Vagrant.configure(2) do |config|
libvirt.memory = 1024
end
config.vm.provision :shell, path: "change-vmdebootstrap-default-dhcp.sh"
config.vm.provision :salt do |salt|
salt.bootstrap_options = "-x python3"
salt.minion_id = "gvaldap"

15
change-vmdebootstrap-default-dhcp.sh

@ -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…
Cancel
Save