There is a problem with deployments, where the main Ethernet interface is any other except eth0 and Cloud-Init needs to fetch meta-data from the network.
Unfortunately, Cloud-Init has limited variants of ways for network configuration before a stage where it needs to fetch meta-data:
- configuration file
- kernel command line
- initramfs config
- fallback DHCP client on eth0
In the vast majority of cases, DHCP on eth0 does the work. But not in this one.
From these options, we cannot use initramfs because we do not initiate the network there (except PXE boot, but this is another story) and kernel command line, because we cannot modify it dynamically (actually, this is not 100% true, but performing Ethernet interfaces analysis from GRUB, seems to be too much if possible at all).
So, there is one sensible place where we still can do something - Cloud-Init configuration. I think we need to write a systemd service that will start before Cloud-Init, check all available interfaces for the DHCP server, and add this information to the Cloud-Init config. This will solve the problem (already tested).