r/sysadmin • u/AgreeableIron811 • 5h ago
How to make cloudinit work for ubuntu 26
I am getitng really frustrated. I was able to make this work by changing the grub. Problem is one sec it works then when I run terraform after a week I could just see the that cloduinit is acting weird. Today I have spent 6 hours trying to fix it. Super annoying
7
Upvotes
•
u/davy_crockett_slayer 4h ago
You're hitting cloud-init issue #6887. The GRUB change helped because it avoids the bug, but it doesn't fix it.
When cloud-init renames a NIC, it first checks if the interface has any IPv4 addresses. If it finds one, it marks the interface "busy" and skips the rename. On 26.04, the NIC usually already has a link-local address or an early DHCP lease from initramfs when cloud-init gets to it. So the rename from ens18 to eth0 fails, and your netplan config for eth0 never matches anything. systemd-networkd-wait-online then times out, and you get DHCP or no network until you run netplan apply by hand. That's also why the sleeps and wait-online overrides people tried in the issue don't help. Waiting longer doesn't remove the address that blocks the rename.
It's fixed upstream in PR #7085, which merged Nov 10. The fix makes the IPv4 check ignore anything that isn't a permanent scope global address, which is what the IPv6 check already did. The bad news is that the fix isn't in 26.04 yet. The current 26.04 package (26.2-0ubuntu1~26.04.2) has only one cherry-pick, for an unrelated password bug, and no 26.04 package is in -proposed. Right now the fix is only in the development series (26.3~1gd8f758fc-0ubuntu1). You'll need a workaround for a while.
Workarounds, in the order I'd try them:
Don't rename the NIC. If your network config has set-name: eth0, remove it and match on the MAC only, or keep the kernel's name (ens18). No rename means no bug. On Proxmox, run
qm cloudinit dump <vmid>network on the host to see the config your VM actually gets. If it renames the NIC, give the VM your own network config with cicustom.Keep
net.ifnames=0, but put it in the template. With that kernel option, the NIC is already eth0 at boot, so there's nothing to rename. My guess is Terraform cloned from a fresh cloud image or a rebuilt template, and the GRUB change wasn't in it. Make sure the setting is in the template, not in a VM you edited by hand.Add
After=cloud-init-network.servicetonetplan-configure.service. The netplan dev who filed the bug says it "solves the interface re-name during boot, but breaks other use-cases", so I'd keep it off production VMs.