2026-01-17 11:58:04 -08:00
|
|
|
"""Pulumi program to manage tail8d86e.ts.net tailnet configuration.
|
|
|
|
|
|
|
|
|
|
This program manages:
|
|
|
|
|
- ACL policy (grants, SSH rules, tag owners, tests)
|
|
|
|
|
- Device tags for infrastructure classification
|
|
|
|
|
|
|
|
|
|
Devices are tagged based on their role:
|
|
|
|
|
- tag:homelab - Server infrastructure (indri)
|
|
|
|
|
- tag:workstation - Development machines that can manage homelab (gilbert)
|
|
|
|
|
- tag:nas - Network-attached storage (sifaka)
|
|
|
|
|
- tag:blumeops - Resources managed by this IaC
|
|
|
|
|
- Service tags (grafana, forge, etc.) - Fine-grained service access control
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import hashlib
|
2026-01-15 20:55:25 -08:00
|
|
|
|
|
|
|
|
import pulumi
|
|
|
|
|
import pulumi_tailscale as tailscale
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
# Read the HuJSON policy file
|
|
|
|
|
policy_path = Path(__file__).parent / "policy.hujson"
|
|
|
|
|
policy_content = policy_path.read_text()
|
|
|
|
|
|
2026-01-17 11:58:04 -08:00
|
|
|
# Compute policy hash for change tracking
|
|
|
|
|
policy_hash = hashlib.sha256(policy_content.encode()).hexdigest()[:12]
|
|
|
|
|
|
2026-01-15 20:55:25 -08:00
|
|
|
# Manage the ACL - this completely overwrites the tailnet's ACL policy
|
|
|
|
|
acl = tailscale.Acl(
|
|
|
|
|
"tailnet-acl",
|
|
|
|
|
acl=policy_content,
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-16 12:30:20 -08:00
|
|
|
# ============== Device Tags ==============
|
2026-01-17 11:58:04 -08:00
|
|
|
# Manage tags for devices in the tailnet.
|
|
|
|
|
# Tags control access via the ACL policy in policy.hujson.
|
2026-01-16 12:30:20 -08:00
|
|
|
|
2026-01-17 11:58:04 -08:00
|
|
|
# indri - Mac Mini M1, primary homelab server
|
|
|
|
|
# Hosts all user-facing services (grafana, forge, kiwix, etc.)
|
2026-01-16 12:30:20 -08:00
|
|
|
indri = tailscale.get_device(name="indri.tail8d86e.ts.net")
|
|
|
|
|
indri_tags = tailscale.DeviceTags(
|
|
|
|
|
"indri-tags",
|
|
|
|
|
device_id=indri.node_id,
|
|
|
|
|
tags=[
|
2026-01-17 11:58:04 -08:00
|
|
|
"tag:homelab", # Server role - allows SSH from workstations
|
|
|
|
|
"tag:blumeops", # Managed by this IaC
|
|
|
|
|
# Service tags - enable fine-grained access control per service
|
2026-01-16 12:30:20 -08:00
|
|
|
"tag:grafana",
|
|
|
|
|
"tag:forge",
|
|
|
|
|
"tag:kiwix",
|
|
|
|
|
"tag:devpi",
|
|
|
|
|
"tag:loki",
|
|
|
|
|
"tag:pg",
|
|
|
|
|
"tag:feed",
|
2026-01-18 12:06:28 -08:00
|
|
|
"tag:registry", # Zot container registry
|
2026-01-18 12:49:20 -08:00
|
|
|
"tag:k8s-api", # Kubernetes API server
|
2026-01-16 12:30:20 -08:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2026-01-17 11:58:04 -08:00
|
|
|
# NOTE: gilbert (MacBook Air M4) is NOT tagged via Pulumi
|
|
|
|
|
# Tagging a user-owned device converts it to a "tagged device" which loses
|
|
|
|
|
# user identity, breaking user-based SSH rules. gilbert remains user-owned
|
|
|
|
|
# so blume.erich@gmail.com can SSH to homelab via the ACL rules.
|
|
|
|
|
|
|
|
|
|
# sifaka - Synology NAS, backup target
|
|
|
|
|
# Homelab and workstations can access for backups
|
|
|
|
|
sifaka = tailscale.get_device(name="sifaka.tail8d86e.ts.net")
|
|
|
|
|
sifaka_tags = tailscale.DeviceTags(
|
|
|
|
|
"sifaka-tags",
|
|
|
|
|
device_id=sifaka.node_id,
|
|
|
|
|
tags=[
|
|
|
|
|
"tag:nas", # NAS role - accessible by homelab and workstations
|
|
|
|
|
"tag:blumeops", # Managed by this IaC
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# ============== Exports ==============
|
2026-01-15 20:55:25 -08:00
|
|
|
pulumi.export("acl_id", acl.id)
|
2026-01-17 11:58:04 -08:00
|
|
|
pulumi.export("policy_hash", policy_hash)
|
|
|
|
|
|
2026-01-16 12:30:20 -08:00
|
|
|
pulumi.export("indri_device_id", indri.node_id)
|
|
|
|
|
pulumi.export("indri_tags", indri_tags.tags)
|
2026-01-17 11:58:04 -08:00
|
|
|
|
|
|
|
|
pulumi.export("sifaka_device_id", sifaka.node_id)
|
|
|
|
|
pulumi.export("sifaka_tags", sifaka_tags.tags)
|