Per Daniel's suggestion, we can deliver a static netplan yaml in Azure netplan-enabled cloud-images. But, that netplan needs to complement the original 50-cloud-init.yaml which will not be updated by cloud-init after first boot.
We can then also drop the udev rules and the changes I made to ephemeral_eth.sh script as that would be completely unused in netplan environments.
This way we don't have to run netplan apply on each udev add event.
The static netplan is as follows:
/etc/netplan/90-hotplug-azure.yaml
# Automatically generated by /usr/local/sbin/ephemeral_eth.sh to setup
# Azure attached nics after initial instance boot
network:
version: 2
ethernets:
ephemeral:
dhcp4: true
match: driver: hv_netvsc name: '!eth0' optional: true hotpluggedeth0:
dhcp4: true
match: driver: hv_netvsc name: 'eth0'
OK I changed up the approach here after some good testing on Azure (attaching new nics, detatching original eth0 nic, reattaching nics etc).
systemd does let us pass inverted matches per https:/ /www.freedeskto p.org/software/ systemd/ man/systemd. network. html#Name=
Per Daniel's suggestion, we can deliver a static netplan yaml in Azure netplan-enabled cloud-images. But, that netplan needs to complement the original 50-cloud-init.yaml which will not be updated by cloud-init after first boot.
We can then also drop the udev rules and the changes I made to ephemeral_eth.sh script as that would be completely unused in netplan environments.
This way we don't have to run netplan apply on each udev add event.
The static netplan is as follows: 90-hotplug- azure.yaml sbin/ephemeral_ eth.sh to setup
driver: hv_netvsc
name: '!eth0'
optional: true
hotpluggedeth0 :
driver: hv_netvsc
name: 'eth0'
/etc/netplan/
# Automatically generated by /usr/local/
# Azure attached nics after initial instance boot
network:
version: 2
ethernets:
ephemeral:
dhcp4: true
match:
dhcp4: true
match: