network and serial complete

This commit is contained in:
2023-08-10 23:32:17 +10:00
parent 621d9595f8
commit 84a20416e3
19 changed files with 142 additions and 40 deletions

View File

@ -0,0 +1,9 @@
[NetDev]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }}
Kind=bridge
[Bridge]
DefaultPVID=none
VLANFiltering={{ item.vlan_filtering | default(false)}}
VLANProtocol=802.1q
STP={{ item.stp | default(false) }}

View File

@ -0,0 +1,15 @@
[Match]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.network', '') }}
[Link]
ARP={{ item.arp | default(true) }}
[Network]
DHCP={{ item.dhcp | default(true) }}
LinkLocalAddressing=False
LLDP={{ item.lldp | default(true) }}
{% if item.vlans is defined -%}
{% for vlan in item.vlans -%}
VLAN={{ item.vlan }}
{% endfor -%}
{% endif -%}

View File

@ -0,0 +1,8 @@
[Match]
PermanentMACAddress={{ item.mac_address }}
[Link]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.link', '') }}
MACAddressPolicy=permanent
MACAddress={{ item.mac_address }}

View File

@ -0,0 +1,73 @@
[Match]
MACAddress={{ item.mac_address }}
[Link]
ARP={{ item.arp | default(true) }}
[Network]
DHCP={{ item.dhcp | default(true) }}
LinkLocalAddressing=False
LLDP={{ item.lldp | default(true) }}
{% if item.nameserver is defined and item.nameserver.ipv4 is defined -%}
{% for nameserver in item.nameserver.ipv4 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.nameserver is defined and item.nameserver.ipv6 is defined -%}
{% for nameserver in item.nameserver.ipv6 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.bond is defined -%}
Bond={{ item.bond }}
{% endif -%}
{% if item.bridge is defined -%}
Bridge={{ item.bridge.name }}
{% endif -%}
{% if item.vlans is defined -%}
{% for vlan in item.vlans -%}
VLAN={{ vlan }}
{% endfor -%}
{% endif -%}
{% if item.address is defined %}
[Address]
{% if item.address.ipv4 is defined -%}
{% for address in item.address.ipv4 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% if item.address.ipv6 is defined -%}
{% for address in item.address.ipv6 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv4 is defined %}
[Route]
Destination=0.0.0.0/0
Gateway={{ item.gateway.ipv4 }}
Scope=global
Protocol=static
Type=unicast
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv6 is defined %}
[Route]
Destination=::/0
Gateway={{ item.gateway.ipv6 }}
Protocol=static
Type=unicast
{% endif -%}
{% if item.bridge is defined and item.bridge.vlans is defined %}
[BridgeVLANs]
{% for vlan in item.bridge.vlans -%}
VLAN={{ vlan }}
{% endfor -%}
{% if item.bridge.pvid is defined -%}
PVID={{ item.bridge.pvid }}
EgressUntagged={{ item.bridge.pvid }}
{% endif -%}
{% endif -%}

View File

@ -0,0 +1,7 @@
[NetDev]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }}
Kind=vlan
[VLAN]
Id={{ item.vlan_id }}
Protocol=802.1q

View File

@ -0,0 +1,51 @@
[Match]
Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.network', '') }}
[Link]
ARP={{ item.arp | default(true) }}
[Network]
DHCP={{ item.dhcp | default(true) }}
LinkLocalAddressing=False
LLDP={{ item.lldp | default(true) }}
{% if item.nameserver is defined and item.nameserver.ipv4 is defined -%}
{% for nameserver in item.nameserver.ipv4 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.nameserver is defined and item.nameserver.ipv6 is defined -%}
{% for nameserver in item.nameserver.ipv6 -%}
DNS={{ nameserver }}
{% endfor -%}
{% endif -%}
{% if item.address is defined %}
[Address]
{% if item.address.ipv4 is defined -%}
{% for address in item.address.ipv4 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% if item.address.ipv6 is defined -%}
{% for address in item.address.ipv6 -%}
Address={{ address }}
{% endfor -%}
{% endif -%}
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv4 is defined %}
[Route]
Destination=0.0.0.0/0
Gateway={{ item.gateway.ipv4 }}
Scope=global
Protocol=static
Type=unicast
{% endif -%}
{% if item.gateway is defined and item.gateway.ipv6 is defined %}
[Route]
Destination=::/0
Gateway={{ item.gateway.ipv6 }}
Protocol=static
Type=unicast
{% endif -%}