about summary refs log tree commit diff
path: root/bundles/tailscale/items.py
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2025-09-07 17:32:13 +0200
committerRobert Günzler <r@gnzler.io>2025-09-07 17:42:42 +0200
commit38be6c13f76e893cf47636257071b440dec0c5b2 (patch)
treef7ded3235a7e3362cbd1ed3d91523968fe0faf90 /bundles/tailscale/items.py
initial commit
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/tailscale/items.py')
-rw-r--r--bundles/tailscale/items.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/bundles/tailscale/items.py b/bundles/tailscale/items.py
new file mode 100644
index 0000000..ca0b557
--- /dev/null
+++ b/bundles/tailscale/items.py
@@ -0,0 +1,39 @@
+if node.os != "alpine":
+    raise BundleError(f"{node.name}: OS {node.os} is not supported.")
+
+svc_openrc = {
+    "tailscale": {
+        "enabled": True,
+        "running": True,
+        "needs": [
+            "pkg_apk:tailscale",
+        ],
+    },
+}
+
+
+tailscale_authkey = node.metadata.get("tailscale/authkey", None)
+if not tailscale_authkey:
+    raise KeyError
+
+actions = {
+    "tailscale_up": {
+        "command": f"tailscale up --authkey={tailscale_authkey}",
+        "needs": [
+            "pkg_apk:tailscale",
+            "svc_openrc:tailscale",
+        ],
+        "unless": "tailscale ip -1 >/dev/null 2>&1",
+    },
+    "tailscale_advertise_exit_node": {
+        "command": "tailscale set --advertise-exit-node",
+        "interactive": False,  # doesn't hurt to run every time
+        "needs": [
+            "pkg_apk:tailscale",
+            "svc_openrc:tailscale",
+            # "action:tailscale_up", ?
+        ],
+    },
+}
+
+# TODO: metrics https://forum.tailscale.com/t/monitor-tailscale-by-prometheus/2315