netplan merge wildcard section with exact ifaces

Asked by Dmitrii Popov

We have such a configuration:

network:
  version: 2
  renderer: networkd
  ethernets:
    zz-all-en:
      match:
        name: "en*"
      dhcp-identifier: "mac"
    ens192:
      match:
        macaddress: "00:50:56:9e:16:8a"
      dhcp4: true
      set-name: "ens192"
Interface ens192 matches name pattern "en*" but rule dhcp-identifier: "mac" is not applied to this iface - after server reboot DHCP register lease by UID (not MAC address). I want to use a common section like zz-all-en in my packer template and at the same time exact interface sections like ens192 (they are added by terraform for exact VM). How should I write such common section?

OS: ubuntu 22.04 LTS cloud-init --version 23.3.3-0ubuntu0~22.04.1 netplan: 0.106.1-7ubuntu0.22.04.2

I can update cloud-init to 24.1.1

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu netplan.io Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Lukas Märdian (slyon) said :
#1

Yes, it will only match the first interface, ignoring your "zz-*" definition.

I suppose you could use YAML anchor/alias, to copy that value around, but there's not big benefit against just copying the value directly.

E.g.:

network:
  version: 2
  renderer: networkd
  ethernets:
    zz-all-en:
      match:
        name: "en*"
      dhcp-identifier: &template "mac"
    ens192:
      dhcp-identifier: *template
      match:
        macaddress: "00:50:56:9e:16:8a"
      dhcp4: true
      set-name: "ens192"

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.