From aefa7a4f57f91ed62ca166ecf5fdfc2eacc04f6a Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 23 Jan 2021 22:17:02 +0100 Subject: move wireguard to network sub-dir --- roles/wireguard/p2p/tasks/main.yml | 20 ----------- .../p2p/tasks/systemd-iptables.service.j2 | 42 ---------------------- 2 files changed, 62 deletions(-) delete mode 100644 roles/wireguard/p2p/tasks/main.yml delete mode 100644 roles/wireguard/p2p/tasks/systemd-iptables.service.j2 (limited to 'roles/wireguard/p2p/tasks') diff --git a/roles/wireguard/p2p/tasks/main.yml b/roles/wireguard/p2p/tasks/main.yml deleted file mode 100644 index 78cfaf43..00000000 --- a/roles/wireguard/p2p/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: install wireguard interfaces (netdev) - template: - src: systemd.netdev.j2 - dest: "/etc/systemd/network/{{ wireguard_p2p_interface.name }}.netdev" - mode: 0640 - group: systemd-network - notify: restart systemd-networkd - -- name: install wireguard interfaces (network) - template: - src: systemd.network.j2 - dest: "/etc/systemd/network/{{ wireguard_p2p_interface.name }}.network" - notify: restart systemd-networkd - -- name: enable systemd-networkd - systemd: - name: systemd-networkd - enabled: yes - state: started diff --git a/roles/wireguard/p2p/tasks/systemd-iptables.service.j2 b/roles/wireguard/p2p/tasks/systemd-iptables.service.j2 deleted file mode 100644 index 11cf4b8a..00000000 --- a/roles/wireguard/p2p/tasks/systemd-iptables.service.j2 +++ /dev/null @@ -1,42 +0,0 @@ -[Unit] -Wants=network-online.target -After=network-online.target - - -[Service] -Type=oneshot - -{% if 'ip_snat' in item.value %} -ExecStart=/usr/sbin/sysctl net.ipv4.ip_forward=1 -{% for addr in item.value.addresses %} -ExecStart=/sbin/iptables -t nat -A POSTROUTING -s {{ addr | ipaddr('network/prefix') }} -o {{ item.value.ip_snat.interface }} -j SNAT --to {{ item.value.ip_snat.to }} -{% endfor %} -{% endif %} -{% for forward in item.value.port_forwardings | default([]) %} -{% for port in forward.tcp_ports | default([]) %} -ExecStart=/sbin/iptables -t nat -A PREROUTING -d {{ forward.dest }} -p tcp --dport {{ port }} -j DNAT --to {{ forward.tcp_ports[port] }} -{% endfor %} -{% for port in forward.udp_ports | default([]) %} -ExecStart=/sbin/iptables -t nat -A PREROUTING -d {{ forward.dest }} -p udp --dport {{ port }} -j DNAT --to {{ forward.udp_ports[port] }} -{% endfor %} -{% endfor %} - -{% if 'ip_snat' in item.value %} -{% for addr in item.value.addresses %} -ExecStop=/sbin/iptables -t nat -D POSTROUTING -s {{ addr | ipaddr('network/prefix') }} -o {{ item.value.ip_snat.interface }} -j SNAT --to {{ item.value.ip_snat.to }} -{% endfor %} -{% endif %} -{% for forward in item.value.port_forwardings | default([]) %} -{% for port in forward.tcp_ports | default([]) %} -ExecStop=/sbin/iptables -t nat -D PREROUTING -d {{ forward.dest }} -p tcp --dport {{ port }} -j DNAT --to {{ forward.tcp_ports[port] }} -{% endfor %} -{% for port in forward.udp_ports | default([]) %} -ExecStop=/sbin/iptables -t nat -D PREROUTING -d {{ forward.dest }} -p udp --dport {{ port }} -j DNAT --to {{ forward.udp_ports[port] }} -{% endfor %} -{% endfor %} - -RemainAfterExit=yes - - -[Install] -WantedBy=multi-user.target -- cgit v1.2.3