feat: support multiple routes and addresses, support wireguard
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Markus Pesch 2022-04-18 16:35:41 +02:00
parent 1141bf02a8
commit ef98355d71
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
3 changed files with 79 additions and 9 deletions

View File

@ -16,6 +16,7 @@ systemd_networkd_netdev: []
# - key: LACPRransmitRate
# value: fast
# filename: 10-bo0.netdev
#
# - netdev_options:
# - key: Name
# value: br0
@ -23,6 +24,31 @@ systemd_networkd_netdev: []
# value: Bridge
# bridge_options: {}
# filename: 10-br0.netdev
#
# - netdev_options:
# - key: Name
# value: wg0
# - key: Kind
# value: wireguard
# wireguard_options:
# - key: PrivateKey
# value: "my-priv-key"
# - key: ListenPort
# value: "51820"
# wireguard_peers:
# - name: "a description"
# options:
# - key: PublicKey
# value: "public-key-of-remote-peer"
# - key: PresharedKey
# value: "preshared-key"
# - key: AllowedIPs
# value: "allowd-ips"
# - key: PersistentKeepalive
# value: "25"
# - key: Endpoint
# value: my-endpoint
# filename: 10-wireguard.netdev
systemd_networkd_network: []
# - match_options:
@ -42,6 +68,7 @@ systemd_networkd_network: []
# - key: RouteMetric
# value: 20
# filename: 20-wlp.network
#
# - match_options:
# - key: Name
# value: bo0
@ -60,5 +87,26 @@ systemd_networkd_network: []
# dhcp_options:
# - key: RouteMetric
# value: 10
#
# - match_options:
# - key: Name
# value: wg0
# network_options:
# - key: DNS
# value: "1.2.3.4"
# - key: DNSDefaultRoute
# value: "false"
# addresses:
# - options:
# - key: Address
# value: "192.168.178.100/32"
# routes:
# - name: VPN-Network
# options:
# - key: Destination
# value: "192.168.178.0/24"
# - key: Gateway
# value: "192.168.178.100"
# filename: "50-wireguard.network"
systemd_timesyncd_timezone: Europe/Berlin

View File

@ -1,3 +1,4 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
#
# {{ ansible_managed }}
#
@ -30,9 +31,17 @@
{% endfor %}
{% endif %}
{% if item.wireguard_peer_options is defined and item.wireguard_peer_options | length > 0 %}
{% if item.wireguard_peers is defined %}
{% for wireguard_peer in item.wireguard_peers %}
{% if wireguard_peer.options is defined and wireguard_peer.options | length > 0 %}
{% if wireguard_peer.name is defined and wireguard_peer.name | length > 0 %}
# {{ wireguard_peer.name }}
{% endif %}
[WireGuardPeer]
{% for wireguard_peer_option in item.wireguard_peer_options %}
{{ wireguard_peer_option.key }}={{ wireguard_peer_option.value }}
{% for option in wireguard_peer.options %}
{{ option.key }}={{ option.value }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

View File

@ -24,19 +24,32 @@
{% endfor %}
{% endif %}
{% if item.addresses is defined and item.addresses | length > 0 %}
{% if item.addresses is defined %}
{% for address in item.addresses %}
{% if address.options is defined and address.options | length > 0 %}
{% if address.name is defined and address.name | length > 0 %}
# {{ address.name }}
{% endif %}
[Address]
{% for address_option in address.options %}
{{ address_option.key }}={{ address_option.value }}
{% for option in address.options %}
{{ option.key }}={{ option.value }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% if item.route_options is defined and item.route_options | length > 0 %}
{% if item.routes is defined %}
{% for route in item.routes %}
{% if route.options is defined and route.options | length > 0 %}
{% if route.name is defined and route.name | length > 0 %}
# {{ route.name }}
{% endif %}
[Route]
{% for route_option in item.route_options %}
{{ route_option.key }}={{ route_option.value }}
{% for option in route.options %}
{{ option.key }}={{ option.value }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}