Create network interfaces during tiny-cloud early
For the upstream alpine release images we need something that can configure the system (eg #35) at first boot.
We need create the /etc/network/intrfaces
if it is missing. This needs to happen during early phase.
If the interfaces
file is missing, the openrc network service will fail, and openrc will not even try to start tiny-cloud main phase due to unsuccessful network.
We cannot use after net
instead of need net
because it will mean that nothing will pull in network.
We cannot ship a default interfaces file because we don't know anything at all about what network hardware is available during build time. Maybe there is no ethernet, maybe its only wifi, maybe it is no network at all (for like embedded controllers). We cannot assume anything at all during build of iso.
We can not generate the interfaces file from post-install, because the network kernel module may not be loaded. The release iso images will by default create a tmpfs root from initramfs, and install the base system there. The only job initramfs has is to mount root, so typically it only has disk drivers, crypto, raid, cdrom, etc. It usually don't have network drivers (those are loaded later during boot). This means we don't know what network hardware we have during install time (eg post-install).
So we need configure the /etc/network/interfaces
after initramfs, after hardware drivers are loaded/coldplugged (openrc's hwdrivers
) but before network. So it makes sense to do it from tiny-cloud early
.
Option 1:
Run assemble-interfaces
. We could move the assemble-interfaces
tiny-cloud's main package and execute that.
Option 2:
Add support for NoCloud's legacy network-interfaces
in the meta-data.
This is what I did in my draft MR. !42 (3c66b9e4)
Option 3:
Add support for a subset of cloud-init's network-config v2
In any case, if no network config is provided in any form, we should fall back to some sort of auto detected default, similar to what assemble-interfaces
does. We could for example test if link status is LOWER_UP
which indicates that cable is connected. This would mean that even if you boot a machine with 4 network ports, it would always configure the one that is connected. (you connect any port and boot, rather than try boot 4 times with a cable in each port to try find which port it configures)