canonical / canonical/cloud-init

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

Open
#6,266 2 comments 0 reactions 0 assignees View on GitHub
enhancement incomplete
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
3d 8h
Merged PRs (30d)
22

Description

# Enhancement

We're currently migrating our [CloudLab](https://www.cloudlab.us/) 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](https://github.com/canonical/cloud-init/commit/1a40fc99a587bc89f55423719f4fd9019e450b89) (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

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the linked commit 1a40fc99a587bc89f55423719f4fd9019e450b89 and the issue's kernel-cmdline and NoCloud network-config flow. Determine the intended merge behavior and edge cases when both sources are present; done means maintainers agree on the generalized scope and the behavior is covered by edge-case testing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.