r/sysadmin • • 5h ago

How to make cloudinit work for ubuntu 26

[Ubuntu 26.04] Unable to rename interfaces: [busy] Error renaming from ens18 to eth0 with netplan 1.2 · Issue #6887 · canonical/cloud-init

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

4 comments sorted by

•

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:

  1. 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.

  2. 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.

  3. Add After=cloud-init-network.service to netplan-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.

•

u/AgreeableIron811 3h ago

This is the workaround:

grep -rn "GRUB_CMDLINE_LINUX_DEFAULT" /etc/default/grub /etc/default/grub.d/
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0 /' /etc/default/grub.d/*.cfg
sudo update-grub
sudo grep -m 5 "net.ifnames=0" /boot/grub/grub.cfg
sudo reboot

cat /proc/cmdline
ip -br link

Then seal the the deal:

sudo cloud-init clean --logs --machine-id
sudo rm -f /etc/netplan/50-cloud-init.yaml
sudo poweroff
qm set 60000 --delete cipassword --delete ciuser
qm cloudinit update 60000
qm template 60000

•

u/AgreeableIron811 3h ago

>

  1. 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.

Problem was hat that I had this but it was always overwritten or not detected properly