I'm trying to leverage netplan's ability to override configurations with lexicographically later files, but when these files come from another mount point, the whole thing fails.
I've created a virtual machine with a few interfaces, and those are configured with sensible defaults using files like
/etc/netplan/02-local.yaml (which basically say "use dhcp"). That part works well. However what I'm trying to achieve is the ability to override the settings using an optional drive mount.
For this I have added a mount point to
/etc/fstab with the following contents:
/dev/vdb /mnt/config ext4 defaults,nofail,x-systemd.device-timeout=10,x-systemd.before=systemd-networkd.service 0 0
And then I added symlinks to
/etc/netplan that point to new config files, such as
ln -s /mnt/config/netplan/11-primary.yaml /etc/netplan/11-primary.yaml.
My first problem was that if the drive is not present and mounted, the whole netplan generate fails at boot time and I am left without any interfaces (I have issued a bug report about missing symlinks to netplan). I managed to overcome this issue by simply creating the necessary directory structure with empty files in
/mnt/config. However even with the drive present, netplan does not see these files at boot time. If I run
netplan generate and
netplan apply after boot, all the interfaces get configured correctly.
I have tried many different
x-systemd.before targets but none of them work. Is there any way to get this working correctly? The config mount should be optional so that the virtual machine can be booted without one.