Netplan template macros

The following table describes the main lookup functions, or macros, that can be used in the npTemplate field of an L2 template.

Lookup function

Description

{{nic N}}

Name of a NIC number N. NIC numbers correspond to the interface mapping list. This macro can be used as a key for the elements of ethernets map, or as the value of name and set-name parameters of a NIC. It is also used to reference the physical NIC from definitions of virtual interfaces (vlan, bridge).

{{mac N}}

MAC address of a NIC number N registered during a host hardware inspection.

{{ip "N:subnet-a"}}

IP address and mask for a NIC number N. If the address does not exist yet, it will be automatically allocated from the given subnet. The interface is identified by its MAC address.

{{ip "br0:subnet-x"}}

IP address and mask for a virtual interface, "br0" in this example. The address will be auto-allocated from the given subnet if the address does not exist yet.

{{cidr_from_subnet “subnet-a”}}

IPv4 CIDR address from the given subnet.

{{gateway_from_subnet "subnet-a"}}

IPv4 default gateway address from the given subnet.

{{nameservers_from_subnet "subnet-a"}}

List of the IP addresses of name servers from the given subnet.

{{cluster_api_lb_ip}}

Technology Preview since MOSK 23.2.2. IP address for a cluster API load balancer.