tailscale-policy: terraform module for tagOwners + per-host + per-service tags #134
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Tailnet identity is currently a single dimension - "which Tailscale node" - which doesn't answer "which physical box hosts this." Physical machines (kai-server, kai-desktop-tower, kai-windows-laptop, kais-macbook-pro) and k8s sidecar nodes (one per service in
terraform/tailscale-devices/services.yaml) all sit on the same tailnet with no structured tagging beyondtag:k8s.Goal
Two layers of tags, both IaC-owned:
tag:physical, plus a per-host tag (tag:kai-server,tag:kai-desktop-tower,tag:kai-windows-laptop,tag:kais-macbook-pro).services.yamlgetstag:k8s+tag:<service>+tag:host-<host>(current state assumestag:host-kai-serverfor everything; expand the map when a second k3s host shows up).Design
New module:
terraform/tailscale-policy/.tailscale_acl.policy- owns the full tailnet policy file (tagOwners + ACL rules + grants). One resource, JSON body assembled fromtags.yaml+ the existing rules already in the web console.tailscale_device_tags.physical- for_each over the four physical devices, looked up by MagicDNS name viadata.tailscale_device. Each getstag:physical+ per-host tag.scripts/k8s/terraform_tailscale_policy.py, new coily verbterraform-tailscale-policy.Extend
terraform/tailscale-devices/:services.yamlfrom a flat list to a mapservice -> [tags...](or compute tags inside main.tf from the host map).tailscale_tailnet_key.servicegets the per-service tag list, not baretag:k8s.Bootstrap sequence
coily exec dump-tailscale-acl(also new). Round-trip intoterraform/tailscale-policy/main.tfas the starting policy body.terraform import tailscale_acl.policy <tailnet>.terraform planuntil empty diff against current state.terraform planshows only the additive diff. Apply.Gotchas
tailscale_aclresource owns the whole policy, so the first apply has to be a no-op against current state. Don't skip the import step.tailscale_device_tagsoverwrites the full tag list per device. Make sure the for_each map enumerates the full desired set per host.Out of scope
coilysiren/eco-server,coilysiren/factorio-server, etc. - those keep consuming SSM/coilysiren/<service>/ts-authkey, just with richer tags.Filed by Claude.