TAILSCALE WITH SWAMP
Swamp manages a Tailscale tailnet in two ways. It works through the Tailscale API to configure the tailnet, and through SSH to work on the hosts that run Tailscale. The @swamp/tailscale extension covers the API side. It provides a separate behavior type for each part of the tailnet that the Tailscale API exposes. A tailnet's configuration is written as behavior definitions in a Swamp repository, and its live values are read back into Swamp as data.
Get started
curl -fsSL https://swamp-club.com/install.sh | sh swamp repo init swamp extension pull @swamp/tailscale swamp extension pull @keeb/tailscale swamp extension pull @hivemq/tailscaleWhat @swamp/tailscale covers
The behavior types in @swamp/tailscale fall into these groups:
- Access policy:
policy-file, whosevalidateandpreviewmethods check a policy without saving it - DNS:
dns-configuration,dns-nameservers,dns-preferences,dns-search-pathsanddns-split-nameservers - Credentials:
tailnet-keyfor auth keys,oauth-client,oauth-appandfederated-identity - Devices:
device,device-authorization,device-key,device-tags,device-subnet-routes,device-posture-attribute,device-inviteandposture-integration - People:
user,user-inviteandcontacts - Tailnet-wide settings and events:
tailnet-settings,service,webhookandlog-stream
Every type authenticates the same way. It uses either a Tailscale API access
token or an OAuth client ID and secret. These are set as global arguments or
read from the TAILSCALE_API_KEY, TAILSCALE_OAUTH_CLIENT_ID and
TAILSCALE_OAUTH_CLIENT_SECRET environment variables. Unless a behavior sets
tailnet, it works on the tailnet that the credential belongs to. Tailscale
returns some secrets only once: auth keys, OAuth client and OAuth app secrets,
and webhook signing secrets. Swamp writes these to a vault, not to plain state.
The getting started tutorial pulls the extension and has Tailscale check an access policy held in a behavior. The how-to guides cover three common jobs: creating a tagged auth key for CI runners or servers, routing an internal domain with split DNS, and sending tailnet events to a Slack webhook. Understanding Tailscale automation in Swamp covers how the behavior types relate to the Tailscale API, and how credentials, state and secrets move between them.
Community extensions
Several community extensions work on hosts instead of the API.
@keeb/tailscale installs Tailscale on Alpine VMs
over SSH and authenticates them with an auth key.
@bitgnome/tailscale joins the hosts of an
@swamp/ssh fleet to the tailnet, using an auth key taken from a vault. Both
extensions also parse tailscale status JSON into one resource per machine, so
other behaviors and workflows can look up nodes by name.
@hivemq/tailscale rolls Tailscale out to
bare-metal hosts in a sequence that stops at the first failure: first a canary
group, then the fleet, then sshd hardening.
@josephholsten/tailscale/device
manages TCP serve rules on a device over SSH.
Other extensions add checks and safeguards around the tailnet. @bixu/tailscale-community and @sntxrr/tailscale-acl-drift compare the live policy with a policy file kept in version control and propose ACL changes as pull requests. @mgreten/tailscale-oauth-client replaces an OAuth client in stages, with a preview and a confirmation before each irreversible step. @bixu/tailnet-healthcheck reports devices that run outdated Tailscale clients. @sntxrr/tailcat-probe measures reachability and throughput to a tailcat server. The extensions reference lists the behavior types, arguments and methods of each extension.
Tailscale documentation
Getting started with Tailscale in Swamp
Pull the @swamp/tailscale extension, create a policy file behavior, validate it, and run it against your tailnet to read and check the access policy in Swamp.
Tutorials →Create a tagged, preauthorized Tailscale auth key
Create a reusable, ephemeral, preauthorized Tailscale auth key with tags using the tailnet-key behavior, so the generated key secret is kept in a Swamp vault.
How-to Guides →Route an internal domain with Tailscale split DNS
Point a private domain at internal resolvers with the dns-split-nameservers behavior, check the definition offline, then apply and refresh it on your tailnet.
How-to Guides →Send Tailscale tailnet events to a Slack webhook
Subscribe a Slack endpoint to Tailscale node and user events with the webhook behavior, send a test event, and rotate the signing secret stored in a vault.
How-to Guides →Tailscale extensions
Every Swamp extension for Tailscale: behavior types, global arguments, methods, vault configuration and the data each one writes, read from the registry.
Reference →Understanding Tailscale automation in Swamp
How the @swamp/tailscale behavior types map onto the Tailscale API, how credentials, state and secrets flow, and what teams decide before managing a tailnet.
Explanation →