---
{% set mtu_list = [ctlplane_mtu] %}
{% for network in role_networks %}
{{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }}
{%- endfor %}
{% set min_viable_mtu = mtu_list | max %}
network_config:
- type: linux_bridge
  name: bridge_name
  mtu: {{ min_viable_mtu }}
  use_dhcp: false
  dns_servers: {{ ctlplane_dns_nameservers }}
  domain: {{ dns_search_domains }}
  addresses:
  - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
  routes: {{ [ctlplane_host_routes] | flatten | unique }}
  members:
  - type: interface
    name: interface_name
    mtu: {{ min_viable_mtu }}
    primary: true
- type: vlan
  mtu: {{ storage_mtu }}
  vlan_id: {{ storage_vlan_id }}
  device: bridge_name
  addresses:
  - ip_netmask: {{ storage_ip }}/{{ storage_cidr }}
  routes: {{ [storage_host_routes] | flatten | unique }}
- type: vlan
  mtu: {{ storage_mgmt_mtu }}
  vlan_id: {{ storage_mgmt_vlan_id }}
  device: bridge_name
  addresses:
  - ip_netmask: {{ storage_mgmt_ip }}/{{ storage_mgmt_cidr }}
  routes: {{ [storage_mgmt_host_routes] | flatten | unique }}
- type: vlan
  mtu: {{ internal_api_mtu }}
  vlan_id: {{ internal_api_vlan_id }}
  device: bridge_name
  addresses:
  - ip_netmask: {{ internal_api_ip }}/{{ internal_api_cidr }}
  routes: {{ [internal_api_host_routes] | flatten | unique }}
- type: vlan
  mtu: {{ tenant_mtu }}
  vlan_id: {{ tenant_vlan_id }}
  device: bridge_name
  addresses:
  - ip_netmask: {{ tenant_ip }}/{{ tenant_cidr }}
  routes: {{ [tenant_host_routes] | flatten | unique }}
- type: vlan
  mtu: {{ external_mtu }}
  vlan_id: {{ external_vlan_id }}
  device: bridge_name
  addresses:
  - ip_netmask: {{ external_ip }}/{{ external_cidr }}
  routes: {{ [external_host_routes, [{'default': True, 'next_hop': external_gateway_ip}]] | flatten | unique }}
