feat(tailscale): add the tailscale role #398

Open
Claude wants to merge 2 commits from feat/tailscale-role into main
pull from: feat/tailscale-role
Owner

What and why

Closes #396

Adds tailscale. The role:

  • installs Tailscale from pkgs.tailscale.com, with the keyring pinned by sha256;
  • enables tailscaled;
  • runs tailscale up with an auth key while the node is not Running;
  • can update to the APT candidate version, and remove or purge.

It also updates the README role list and Roadmap (wave 2 is now just pve_vm), the galaxy.yml description, and adds a minor_changes fragment.

Decisions from #396, as applied:

  • No tailscale_system_type. The role asserts Ubuntu, and tailscale_apt_release follows the host's release. It declares noble and resolute.
  • New tailscale_up (default true). The key has no default. A non-empty tailscale_auth_key is asserted before any change, but only when the configure step runs. --tags remove, update and health need no key; the README lists the tags that do. The up block repeats the assert.
  • tailscale_userspace_networking sets --tun=userspace-networking in FLAGS in /etc/default/tailscaled. Other flags and PORT are kept, and setting the input to false removes the flag. When FLAGS changed or tailscaled is not active, the role runs systemctl reset-failed and restarts the daemon at once.
  • No legacy-name guards. Internal names carry __tailscale_.
  • Scenario: a real install, no enrolment. It covers the update path from a downgrade, removal without purge (state dir and defaults kept), a second removal with no unit, a purge on a non-default tailscale_state_dir, and 5 refusal cases.

Deviations from #396, for the maintainer:

  • #396 says molecule tests noble. roles/AGENTS.md ("declared means tested") requires every declared platform to be tested, so the scenario runs noble and resolute, as pihole and docker do.
  • With the configure step selected, tailscale_remove: true still requires the key, because up runs after the logout. Failing after the removal would be worse.

Fixes over the source role, found in an independent review:

  • Removal works on a host with no tailscaled unit.
  • --check --tags configure works on a fresh host.
  • tailscale logout reports a change only when it succeeds.

Unchanged, as in the source role:

  • Any backend state other than Running triggers tailscale up.
  • Only the exact token --tun=userspace-networking is recognised.

Verified

  • Commit hooks (ansible-lint production, yamllint, REUSE, changelog lint, gitleaks) and pre-push ansible-test sanity.
  • --syntax-check on converge/verify, and ansible-doc -t role mortis.kamino.tailscale.
  • verify's refusal cases against localhost: 5/5 stopped on the intended message.
  • The key requirement under real --tags runs on localhost.
  • The FLAGS computation: 7 cases in a scratch play.

Not verified

  • Molecule itself (CI only), including the restart handling and both removal paths.
  • tailscale up and enrolment (excluded by decision).
  • Switching userspace networking back to false on a host (needs /dev/net/tun).
  • The tag check inside the scenario: tags cannot be faked within a play.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code:claude-opus-5-5

🤖 Generated with Claude Code

## What and why Closes #396 Adds `tailscale`. The role: - installs Tailscale from pkgs.tailscale.com, with the keyring pinned by sha256; - enables `tailscaled`; - runs `tailscale up` with an auth key while the node is not Running; - can update to the APT candidate version, and remove or purge. It also updates the README role list and Roadmap (wave 2 is now just `pve_vm`), the galaxy.yml description, and adds a `minor_changes` fragment. Decisions from #396, as applied: - **No `tailscale_system_type`.** The role asserts Ubuntu, and `tailscale_apt_release` follows the host's release. It declares noble and resolute. - **New `tailscale_up`** (default `true`). The key has no default. A non-empty `tailscale_auth_key` is asserted before any change, but only when the configure step runs. `--tags remove`, `update` and `health` need no key; the README lists the tags that do. The `up` block repeats the assert. - **`tailscale_userspace_networking`** sets `--tun=userspace-networking` in `FLAGS` in `/etc/default/tailscaled`. Other flags and `PORT` are kept, and setting the input to false removes the flag. When `FLAGS` changed or `tailscaled` is not active, the role runs `systemctl reset-failed` and restarts the daemon at once. - **No legacy-name guards.** Internal names carry `__tailscale_`. - **Scenario: a real install, no enrolment.** It covers the update path from a downgrade, removal without purge (state dir and defaults kept), a second removal with no unit, a purge on a non-default `tailscale_state_dir`, and 5 refusal cases. **Deviations from #396, for the maintainer:** - #396 says molecule tests `noble`. roles/AGENTS.md ("declared means tested") requires every declared platform to be tested, so the scenario runs noble **and** resolute, as pihole and docker do. - With the configure step selected, `tailscale_remove: true` still requires the key, because `up` runs after the logout. Failing after the removal would be worse. **Fixes over the source role**, found in an independent review: - Removal works on a host with no `tailscaled` unit. - `--check --tags configure` works on a fresh host. - `tailscale logout` reports a change only when it succeeds. **Unchanged, as in the source role:** - Any backend state other than Running triggers `tailscale up`. - Only the exact token `--tun=userspace-networking` is recognised. ## Verified - Commit hooks (ansible-lint production, yamllint, REUSE, changelog lint, gitleaks) and pre-push `ansible-test sanity`. - `--syntax-check` on converge/verify, and `ansible-doc -t role mortis.kamino.tailscale`. - verify's refusal cases against localhost: 5/5 stopped on the intended message. - The key requirement under real `--tags` runs on localhost. - The FLAGS computation: 7 cases in a scratch play. ## Not verified - Molecule itself (CI only), including the restart handling and both removal paths. - `tailscale up` and enrolment (excluded by decision). - Switching userspace networking back to false on a host (needs `/dev/net/tun`). - The tag check inside the scenario: tags cannot be faked within a play. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code:claude-opus-5-5 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added the Kind/Feature label 2026-11-26 20:54:47 +00:00
Claude added 2 commits 2026-11-26 20:54:48 +00:00
Installs Tailscale from the upstream APT repository with the keyring
pinned by sha256, enables tailscaled and, with tailscale_up (default
true), runs tailscale up with tailscale_auth_key while the node is not
Running. It can also update to the APT candidate version and remove or
purge.

The role asserts Ubuntu and follows the host's release, and requires a
non-empty auth key before any change whenever tailscale up will run.
tailscale_userspace_networking now sets --tun=userspace-networking in
the FLAGS of /etc/default/tailscaled, where tailscaled reads it, instead
of passing it to tailscale up.

The molecule scenario installs the real package on noble and resolute
without joining a tailnet, and covers the update and purge paths and
the refusal cases.

Closes #396

Assisted-by: Claude Code:claude-opus-5-5
fix(tailscale): harden removal, restarts and the auth key check
Build / build (pull_request) Successful in 29s
Lint / lint (pull_request) Successful in 2m25s
Molecule / molecule (pull_request) Failing after 3m23s
29165a610f
- Removal passes on a host without a tailscaled unit, and the
  best-effort logout reports a change only when it succeeded.
- Under --check the service tasks run only when the unit exists, also
  with --tags configure on a host without the package.
- The auth key is required before any change only when the run includes
  the configure tasks; --tags remove, install and update need none. The
  assert in the up block stays as the hard guard.
- When the flags change or tailscaled is not active, the role clears its
  failure state and restarts it at once, so a daemon the package started
  without a TUN device does not stay in the start limit.
- The health tag is back on the configure include.
- The scenario tests removal without purge (state and defaults kept, a
  second removal passes) and a purge with a state directory the package
  does not delete itself, and waits for tailscaled to be active.

Assisted-by: Claude Code:claude-opus-5-5
CODEOWNERS rules requested review from Defame1297 2026-11-26 20:54:48 +00:00
Some required checks failed
Build / build (pull_request) Successful in 29s
Required
Details
Lint / lint (pull_request) Successful in 2m25s
Required
Details
Molecule / molecule (pull_request) Failing after 3m23s
Required
Details
Some required checks were not successful.
This pull request has official review requests.
This pull request is blocked because it's outdated.
You are not authorized to merge this pull request.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/tailscale-role:feat/tailscale-role
git checkout feat/tailscale-role
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#398