diff wireguard.py @ 259:e45e93a797b0

wg updates
author drewp@bigasterisk.com
date Fri, 26 Jan 2024 12:55:27 -0800
parents db8787bd800e
children 705698800bfb
line wrap: on
line diff
--- a/wireguard.py	Fri Jan 26 12:54:59 2024 -0800
+++ b/wireguard.py	Fri Jan 26 12:55:27 2024 -0800
@@ -2,7 +2,8 @@
 
 from pyinfra import host
 from pyinfra.facts.files import FindInFile
-from pyinfra.operations import apt, files, server, systemd
+from pyinfra.operations import files, systemd
+
 import wireguard_pubkey
 
 # other options:
@@ -37,7 +38,9 @@
         continue
 
     # note- this is specific to the wg0 setup. Other conf files don't use it.
-    wireguard_ip = host.host_data['wireguard_address']
+    wireguard_ip = host.host_data.get('wireguard_address')
+    if wireguard_interface == 'wg0' and wireguard_ip is None:
+        continue
 
     # new pi may fail with 'Unable to access interface: Protocol not supported'. reboot fixes.
 
@@ -66,8 +69,6 @@
                    wireguard_interface=wireguard_interface)
     systemd.service(service=f'{svc}', enabled=True, restarted=True, daemon_reload=True)
 
-    # files.link(path=f'/etc/systemd/system/multi-user.target.wants/{svc}', target='/lib/systemd/system/wg-quick@.service')
-
     systemd.service(service=svc, daemon_reload=True, restarted=True, enabled=True)
 
 # if host.name == 'bang':