Examples
Linux bridge on top of default gw NIC with DHCP
policy
capture:
default-gw: routes.running.destination=="0.0.0.0/0"
base-iface: interfaces.name==capture.default-gw.routes.running.0.next-hop-interface
desiredState:
interfaces:
- name: br1
description: DHCP aware Linux bridge to connect a nic that is referenced by a default gateway
type: linux-bridge
state: up
mac-address: "{{ capture.base-iface.interfaces.0.mac-address }}"
ipv4:
dhcp: true
enabled: true
bridge:
options:
stp:
enabled: false
port:
- name: "{{ capture.base-iface.interfaces.0.name }}"
current state
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
interfaces:
- name: eth1
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: true
enabled: true
generated state
interfaces:
- name: br1
description: DHCP aware Linux bridge to connect a nic that is referenced by a default gateway
type: linux-bridge
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
dhcp: true
enabled: true
bridge:
options:
stp:
enabled: false
port:
- name: eth1
captured states
base-iface:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: true
enabled: true
default-gw:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
Linux bridge on top of default gw NIC without DHCP
policy
capture:
default-gw: routes.running.destination=="0.0.0.0/0"
base-iface: interfaces.name==capture.default-gw.routes.running.0.next-hop-interface
base-iface-routes: routes.running.next-hop-interface==capture.base-iface.interfaces.0.name
bridge-routes: capture.base-iface-routes | routes.running.next-hop-interface:="br1"
desiredState:
interfaces:
- name: br1
description: Linux bridge with base interface as a port
type: linux-bridge
state: up
mac-address: "{{ capture.base-iface.interfaces.0.mac-address }}"
ipv4: "{{ capture.base-iface.interfaces.0.ipv4 }}"
bridge:
options:
stp:
enabled: false
port:
- name: "{{ capture.base-iface.interfaces.0.name }}"
routes:
config: "{{ capture.bridge-routes.routes.running }}"
current state
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
interfaces:
- name: eth1
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: false
enabled: true
generated state
interfaces:
- name: br1
description: Linux bridge with base interface as a port
type: linux-bridge
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: false
enabled: true
bridge:
options:
stp:
enabled: false
port:
- name: eth1
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: br1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: br1
table-id: 254
captured states
base-iface:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: false
enabled: true
default-gw:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
base-iface-routes:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
bridge-routes:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: br1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: br1
table-id: 254
OVS SLB bond between primary and secondary nics
It uses the description
field to filter between primary and secondary NIC.
policy
capture:
primary-nic: interfaces.description == "primary"
secondary-nic: interfaces.description == "secondary"
desiredState:
interfaces:
- name: br1-iface
type: ovs-interface
state: up
mac-address: "{{ capture.primary-nic.interfaces.0.mac-address }}"
ipv4: "{{ capture.primary-nic.interfaces.0.ipv4 }}"
- name: br1
type: ovs-bridge
state: up
bridge:
options:
stp: false
mcast-snooping-enable: false
rstp: false
port:
- name: bond0
link-aggregation:
mode: balance-slb
port:
- name: "{{ capture.primary-nic.interfaces.0.name }}"
- name: "{{ capture.secondary-nic.interfaces.0.name }}"
- name: br1-iface
current state
interfaces:
- name: eth1
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
dhcp: true
enabled: true
- name: eth2
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02
ipv4:
dhcp: true
enabled: true
generated state
interfaces:
- name: br1-iface
type: ovs-interface
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
dhcp: true
enabled: true
- name: br1
type: ovs-bridge
state: up
bridge:
options:
stp: false
mcast-snooping-enable: false
rstp: false
port:
- name: bond0
link-aggregation:
mode: balance-slb
port:
- name: eth1
- name: eth2
- name: br1-iface
captured states
primary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
ipv4:
dhcp: true
enabled: true
secondary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth2
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02
ipv4:
dhcp: true
enabled: true
Set all linux bridges down
policy
capture:
linux-bridges: interfaces.type=="linux-bridge"
linux-bridges-down: capture.linux-bridges | interfaces.state:="down"
desiredState:
interfaces: "{{ capture.linux-bridges-down.interfaces }}"
current state
interfaces:
- name: eth0
type: ethernet
- name: br1
type: linux-bridge
state: up
- name: br2
type: linux-bridge
state: up
- name: br3
type: linux-bridge
state: up
generated state
interfaces:
- name: br1
type: linux-bridge
state: down
- name: br2
type: linux-bridge
state: down
- name: br3
type: linux-bridge
state: down
captured states
linux-bridges:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: br1
type: linux-bridge
state: up
- name: br2
type: linux-bridge
state: up
- name: br3
type: linux-bridge
state: up
linux-bridges-down:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: br1
type: linux-bridge
state: down
- name: br2
type: linux-bridge
state: down
- name: br3
type: linux-bridge
state: down
Convert DHCP aware interface to static addressing
policy
capture:
eth1-iface: interfaces.name == "eth1"
eth1-routes: routes.running.next-hop-interface == "eth1"
dns: dns-resolver.running
desiredState:
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address: "{{ capture.eth1-iface.interfaces.0.ipv4.address }}"
dhcp: false
enabled: true
routes:
config: "{{ capture.eth1-routes.routes.running }}"
dns-resolver:
config: "{{ capture.dns.dns-resolver.running }}"
current state
dns-resolver:
running:
search:
- example.com
- example.org
server:
- 8.8.8.8
- 2001:4860:4860::8888
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: true
enabled: true
generated state
dns-resolver:
config:
search:
- example.com
- example.org
server:
- 8.8.8.8
- 2001:4860:4860::8888
routes:
config:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: false
enabled: true
captured states
eth1-iface:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
type: ethernet
state: up
ipv4:
address:
- ip: 10.244.0.1
prefix-length: 24
- ip: 169.254.1.0
prefix-length: 16
dhcp: true
enabled: true
eth1-routes:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
routes:
running:
- destination: 0.0.0.0/0
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
- destination: 1.1.1.0/24
next-hop-address: 192.168.100.1
next-hop-interface: eth1
table-id: 254
dns:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
dns-resolver:
running:
search:
- example.com
- example.org
server:
- 8.8.8.8
- 2001:4860:4860::8888
Turn LLDP to true at interfaces active interfaces
policy
capture:
ethernets: interfaces.type=="ethernet"
ethernets-up: capture.ethernets.interfaces.state=="up"
ethernets-lldp: capture.ethernets-up | interfaces.lldp.enabled:=true
desiredState:
interfaces: "{{ capture.ethernets-lldp.interfaces }}"
current state
interfaces:
- accept-all-mac-addresses: false
lldp:
enabled: false
mac-address: 52:55:00:D1:55:01
name: eth0
state: up
type: ethernet
- accept-all-mac-addresses: false
lldp:
enabled: false
mac-address: 52:55:00:D1:56:02
name: eth1
state: down
type: ethernet
- accept-all-mac-addresses: false
mac-address: 52:55:00:D1:57:03
name: eth4
state: up
type: ethernet
- accept-all-mac-addresses: false
mac-address: 52:55:00:D1:56:04
name: eth2
state: down
type: ethernet
generated state
interfaces:
- accept-all-mac-addresses: false
lldp:
enabled: true
mac-address: 52:55:00:D1:55:01
name: eth0
state: up
type: ethernet
- accept-all-mac-addresses: false
lldp:
enabled: true
mac-address: 52:55:00:D1:57:03
name: eth4
state: up
type: ethernet
captured states
ethernets:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- accept-all-mac-addresses: false
lldp:
enabled: false
mac-address: 52:55:00:D1:55:01
name: eth0
state: up
type: ethernet
- accept-all-mac-addresses: false
lldp:
enabled: false
mac-address: 52:55:00:D1:56:02
name: eth1
state: down
type: ethernet
- accept-all-mac-addresses: false
mac-address: 52:55:00:D1:57:03
name: eth4
state: up
type: ethernet
- accept-all-mac-addresses: false
mac-address: 52:55:00:D1:56:04
name: eth2
state: down
type: ethernet
ethernets-up:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- accept-all-mac-addresses: false
lldp:
enabled: false
mac-address: 52:55:00:D1:55:01
name: eth0
state: up
type: ethernet
- accept-all-mac-addresses: false
mac-address: 52:55:00:D1:57:03
name: eth4
state: up
type: ethernet
ethernets-lldp:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- accept-all-mac-addresses: false
lldp:
enabled: true
mac-address: 52:55:00:D1:55:01
name: eth0
state: up
type: ethernet
- accept-all-mac-addresses: false
lldp:
enabled: true
mac-address: 52:55:00:D1:57:03
name: eth4
state: up
type: ethernet
Create a linux-bridge with all the interfaces matching description
policy
capture:
primary-nic: interfaces.description == "primary"
secondary-nic: interfaces.description == "secondary"
desiredState:
interfaces:
- name: br1
type: linux-bridge
state: up
mac-address: "{{ capture.primary-nic.interfaces.0.mac-address }}"
ipv4:
dhcp: true
enabled: true
bridge:
options:
stp:
enabled: false
port:
- name: "{{ capture.primary-nic.interfaces.0.name }}"
- name: "{{ capture.secondary-nic.interfaces.0.name }}"
current state
interfaces:
- name: eth0
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
- name: eth1
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02
generated state
interfaces:
- bridge:
options:
stp:
enabled: false
port:
- name: eth0
- name: eth1
ipv4:
dhcp: true
enabled: true
mac-address: 00:00:5E:00:00:01
name: br1
state: up
type: linux-bridge
captured states
primary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth0
description: primary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:01
secondary-nic:
metaInfo:
time: "2021-12-15T13:45:40Z"
version: "0"
state:
interfaces:
- name: eth1
description: secondary
type: ethernet
state: up
mac-address: 00:00:5E:00:00:02