#1102657 cloud-init - Ec2 instructs netplan to change interface name

#1102657#5
Date:
2025-04-11 14:07:28 UTC
From:
To:
The Ec2 and Azure datasources generate netplan config with "set-name".
Ec2 uses the same name that udev already set, Azure generates a new
"ethX".  This instructs netplan to forcibly change the name, even if
there is a link unit with some other definition.

This "set-name" needs to go in those case.

Bastian

#1102657#10
Date:
2025-04-22 21:05:14 UTC
From:
To:
This all seems to be hardcoded:

            if if_type == "physical":
                # required_keys = ['name', 'mac_address']
                eth = {
                    "set-name": ifname,
                    "match": ifcfg.get("match", None),
                }
                if eth["match"] is None:
                    macaddr = ifcfg.get("mac_address", None)
                    if macaddr is not None:
                        eth["match"] = {"macaddress": macaddr.lower()}
                    else:
                        del eth["match"]
                        del eth["set-name"]
                _extract_addresses(ifcfg, eth, ifname, self.features)
                ethernets.update({ifname: eth})

See
https://github.com/canonical/cloud-init/blob/7a0265d36e01e649f72005548f17dca9ac0150ad/cloudinit/net/netplan.py#L433-L448