cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

[enhancement]: Merging network-config from different sources in cloud-init

Open venkateshdb opened this issue 6 months ago • 2 comments

Enhancement

We're currently migrating our CloudLab environment to use cloud-init, but still rely on a lot of legacy custom code that PXE boots bare-metal servers and configures networking. Because some servers have multiple NICs (and on others the first interface isn't the default DHCP interface), we wrote a patch that modifies the initramfs of our servers to inject a base64-encoded network-config specifying the exact MAC address to use during the init stage.

After boot, we fetch the remainder of the network configuration from a remote server via a seed URL passed in the kernel command line for the NoCloud datasource. However, the kernel-cmdline config always takes precedence, and there's no built-in way to merge the two sources. I've modified the cloud-init code (still in development and pending edge-case testing) to merge the kernel-cmdline and datasource configs when both are present.

I realize this is a very specific use case and the enhancement could be generalized to merge configs from all available sources but I wanted to ask whether the cloud-init maintainers would welcome something like this.

why providing the whole configuration in either the initramfs or the NoCloud URL is not possible?

The initial network configuration for the each machine at the time of boot is provided via the kernel command line. Since each machine has multiple NICs and we allow researchers to configure other interfaces for their experiments, we need a way to provide additional configuration after the initial network setup is complete. However, because the kernel command line network configuration takes precedence over any other source, there is currently no way to provide additional configuration through alternative sources and adding whole config in initramfs will require touching lot of legacy code.

We'd appreciate feedback from the maintainers and community.

distro: Ubuntu 24.04.2 LTS cloudinit version: 24.4.1-0ubuntu0~24.04.3

venkateshdb avatar Jun 12 '25 19:06 venkateshdb

Hi @holmanb, sorry to bother you. I've checked the documentation and issues but couldn't find an answer to this, Can i get your opinion on this.

Thanks!!

venkateshdb avatar Jun 23 '25 22:06 venkateshdb

This is an interesting use case, and indeed - it is quite niche.

However, the kernel-cmdline config always takes precedence, and there's no built-in way to merge the two sources. I've modified the cloud-init code (still in development and pending edge-case testing) to merge the kernel-cmdline and datasource configs when both are present.

I'm not sure that we would want to try to support this in upstream. I think that there are other ways to support this use-case without modifying cloud-init. I think you could probably provide network config on-disk which would then be overridden by that retrieved from the datasource.

holmanb avatar Nov 20 '25 19:11 holmanb