salt.modules.netplan_ip#

The networking module for Debian-family distributions that use netplan (Ubuntu 18.04+, and Debian systems where netplan is the active renderer).

This is the ip execution-module provider behind network.managed on netplan systems. The legacy debian_ip provider writes /etc/network/interfaces (ifupdown), which netplan ignores -- see issue #62219. This provider instead generates per-interface netplan YAML under /etc/netplan/ and applies it with netplan.

New in version 3006.28.

Note

netplan is the source of truth here, so only the subset of the network.managed schema that maps cleanly onto netplan v2 is supported (addresses, gateway, nameservers, mtu, dhcp4/dhcp6). ifupdown-only options such as ethtool offload settings and up/down hook scripts have no netplan equivalent and raise an informative error rather than being silently dropped.

salt.modules.netplan_ip.apply_network_settings(**settings)#

Apply the generated netplan configuration with netplan apply.

CLI Example:

salt '*' ip.apply_network_settings
salt.modules.netplan_ip.build_interface(iface, iface_type, enabled, **settings)#

Build (and, unless test=True, write) the netplan configuration for a network interface. Returns the rendered YAML as a list of lines.

CLI Example:

salt '*' ip.build_interface eth0 eth True ipaddr=10.0.0.5 netmask=255.255.255.0
salt.modules.netplan_ip.build_network_settings(**settings)#

No-op on netplan: there is no global /etc/network equivalent; settings are expressed per interface. Returns an empty list.

CLI Example:

salt '*' ip.build_network_settings
salt.modules.netplan_ip.build_routes(iface, **settings)#

Build the netplan routes for iface. On netplan, routes live inside the interface definition, so this folds the provided routes into the salt-managed interface document. Returns the rendered routes as lines.

CLI Example:

salt '*' ip.build_routes eth0 routes='[{"name": "n", "ipaddr": "10.1.0.0", "netmask": "255.255.0.0", "gateway": "10.0.0.1"}]'
salt.modules.netplan_ip.down(iface, iface_type=None)#

Bring iface down with ip link set <iface> down.

CLI Example:

salt '*' ip.down eth0
salt.modules.netplan_ip.get_interface(iface)#

Return the salt-managed netplan configuration for iface as a list of lines, or an empty list if salt does not manage it yet.

CLI Example:

salt '*' ip.get_interface eth0
salt.modules.netplan_ip.get_network_settings()#

netplan has no separate global network-settings file (the per-interface YAML carries everything). Returns an empty list.

CLI Example:

salt '*' ip.get_network_settings
salt.modules.netplan_ip.get_routes(iface)#

Return the routes currently declared for iface in the salt-managed netplan file, as a list of lines.

CLI Example:

salt '*' ip.get_routes eth0
salt.modules.netplan_ip.netplan_active()#

Return True if netplan appears to be the active network renderer: the netplan command is available and /etc/netplan exists.

CLI Example:

salt '*' ip.netplan_active
salt.modules.netplan_ip.up(iface, iface_type=None)#

Apply the netplan configuration (which brings managed interfaces up).

CLI Example:

salt '*' ip.up eth0