add bridges for ubuntu
This commit is contained in:
parent
3e08fde515
commit
d786b25c5b
2 changed files with 46 additions and 0 deletions
|
@ -1,10 +1,15 @@
|
||||||
---
|
---
|
||||||
interfaces:
|
interfaces:
|
||||||
enp0s3:
|
enp0s3:
|
||||||
|
type: void
|
||||||
|
br0:
|
||||||
ipv4: 10.0.2.9
|
ipv4: 10.0.2.9
|
||||||
netmaskv4: 24
|
netmaskv4: 24
|
||||||
type: static
|
type: static
|
||||||
|
bridge: true
|
||||||
gateway: 10.0.2.1
|
gateway: 10.0.2.1
|
||||||
|
interfaces:
|
||||||
|
- enp0s3
|
||||||
|
|
||||||
ipv4_forwarding: false
|
ipv4_forwarding: false
|
||||||
ipv6_forwarding: false
|
ipv6_forwarding: false
|
||||||
|
|
|
@ -4,6 +4,7 @@ network:
|
||||||
ethernets:
|
ethernets:
|
||||||
{% for item in lookup('dict', interfaces, wantlist=True) %}
|
{% for item in lookup('dict', interfaces, wantlist=True) %}
|
||||||
{% if item.value.type not in ['wireguard', ] %}
|
{% if item.value.type not in ['wireguard', ] %}
|
||||||
|
{% if not ('bridge' in item.value and item.value.bridge) %}
|
||||||
{{ item.key }}:
|
{{ item.key }}:
|
||||||
{% if item.value.type == 'dhcp' %}
|
{% if item.value.type == 'dhcp' %}
|
||||||
dhcp4: true
|
dhcp4: true
|
||||||
|
@ -18,6 +19,45 @@ network:
|
||||||
addresses:
|
addresses:
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
{# the nameservers are hardcoded for now #}
|
{# the nameservers are hardcoded for now #}
|
||||||
|
{% elif item.value.type in ['void', 'manual'] %}
|
||||||
|
dhcp4: false
|
||||||
|
dhcp6: false
|
||||||
|
{% endif %}{# end (type == *) #}
|
||||||
|
{% if 'routes' in item.value %}{# routes #}
|
||||||
|
routes:
|
||||||
|
{% for route in item.value.routes %}
|
||||||
|
- to: {{ route.subnet }}/{{ route.netmask }}
|
||||||
|
via: {{ route.gateway }}
|
||||||
|
metric: 100
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}{# end routes #}
|
||||||
|
{% endif %}{# end not bridge #}
|
||||||
|
{% endif %}{# end (not in [wireguard, ]) #}
|
||||||
|
{% endfor %}
|
||||||
|
{% if (lookup('dict', interfaces, wantlist=True) | selectattr('value.bridge', 'defined') | selectattr('value.bridge') | list) %}
|
||||||
|
bridges:
|
||||||
|
{% for item in (lookup('dict', interfaces, wantlist=True) | selectattr('value.bridge', 'defined') | selectattr('value.bridge') | list) %}
|
||||||
|
{% if item.value.type not in ['wireguard', ] %}
|
||||||
|
{{ item.key }}:
|
||||||
|
{% if 'interfaces' in item.value and item.value.interfaces %}
|
||||||
|
interfaces: [ {{ item.value.interfaces | join(', ') }} ]
|
||||||
|
{% endif %}
|
||||||
|
{% if item.value.type == 'dhcp' %}
|
||||||
|
dhcp4: true
|
||||||
|
{% elif item.value.type == 'static' %}
|
||||||
|
dhcp4: false
|
||||||
|
addresses:
|
||||||
|
- {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
||||||
|
{% if 'gateway' in item.value %}
|
||||||
|
gateway4: {{ item.value.gateway }}
|
||||||
|
{% endif %}
|
||||||
|
nameservers:
|
||||||
|
addresses:
|
||||||
|
- 1.1.1.1
|
||||||
|
{# the nameservers are hardcoded for now #}
|
||||||
|
{% elif item.value.type in ['void', 'manual'] %}
|
||||||
|
dhcp4: false
|
||||||
|
dhcp6: false
|
||||||
{% endif %}{# end (type == *) #}
|
{% endif %}{# end (type == *) #}
|
||||||
{% if 'routes' in item.value %}{# routes #}
|
{% if 'routes' in item.value %}{# routes #}
|
||||||
routes:
|
routes:
|
||||||
|
@ -29,4 +69,5 @@ network:
|
||||||
{% endif %}{# end routes #}
|
{% endif %}{# end routes #}
|
||||||
{% endif %}{# end (not in [wireguard, ]) #}
|
{% endif %}{# end (not in [wireguard, ]) #}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
version: 2
|
version: 2
|
||||||
|
|
Loading…
Reference in a new issue