feat(tailscale): run tailscale up only on a logged-out node, and match the userspace flag in any spelling #403

Open
opened 2026-11-26 21:14:26 +00:00 by Claude · 0 comments
Owner

Two tailscale role behaviours that #398 carried over unchanged from the source role. Both were found in the independent review of #398. Each changes behaviour, so each needs a maintainer decision before an agent picks it up.

1. tailscale up runs on any state other than Running

tasks/configure.yml runs tailscale up --auth-key=file:… whenever BackendState is anything other than Running. That includes an enrolled node that someone stopped with tailscale down (Stopped), and transient states such as Starting. On such a node:

  • up can fail with "requires mentioning all non-default flags", when the node was brought up with other flags earlier;
  • or it fails because the auth key was one-off or has expired. Re-using a key on an enrolled node is the common case, since the key is only needed for first enrolment.

The role then fails a run on a node that is fine, or it silently re-enables a node that an operator took down on purpose.

Proposed: run up only on NeedsLogin or NoState. For Stopped, either leave the node alone and report it, or run a plain tailscale up without the key. With either change, the key assert in validate.yml and in the up block follows the narrower condition.

Decision needed:

  • (a) only NeedsLogin/NoState, and leave Stopped alone (recommended: the role does not override an operator's tailscale down);
  • (b) as (a), but Stopped gets a plain tailscale up;
  • (c) keep the current behaviour and document it.

2. The userspace-networking flag is matched on one spelling only

tasks/configure.yml recognises only the exact token --tun=userspace-networking in FLAGS of /etc/default/tailscaled. Some spellings are neither removed when tailscale_userspace_networking: false nor de-duplicated when true:

  • a hand-written -tun=userspace-networking;
  • --tun userspace-networking (a space instead of =);
  • another --tun=<value>.

So FLAGS can end up with two --tun flags, or keep the flag after the input was turned off.

Proposed: treat any -tun/--tun flag (with = or a space) as the role's own. When true, replace it with --tun=userspace-networking; when false, remove it. Another --tun=<value> is either overwritten or refused with a message.

Decision needed:

  • whether the role owns every --tun flag (overwrite), or refuses a foreign --tun value;
  • whether this is worth the regex at all, given that nothing but the role writes FLAGS on managed hosts.

Tests

  • Molecule: for item 1, a node that is not enrolled stays at NeedsLogin under userspace networking, so only that path can be exercised. Stopped needs an enrolled node, so the state decision is tested at the task level: run with a faked __tailscale_status result in the refusal/assert style of verify.yml. For item 2, seed FLAGS with each spelling in verify.yml, then assert the result for true and for false.
  • Semver: a behaviour change, so minor_changes (breaking_changes if option 1a is called breaking).

Depends on #398.

🤖 Generated with Claude Code

Two `tailscale` role behaviours that #398 carried over unchanged from the source role. Both were found in the independent review of #398. Each changes behaviour, so each needs a maintainer decision before an agent picks it up. ## 1. `tailscale up` runs on any state other than Running `tasks/configure.yml` runs `tailscale up --auth-key=file:…` whenever `BackendState` is anything other than `Running`. That includes an enrolled node that someone stopped with `tailscale down` (`Stopped`), and transient states such as `Starting`. On such a node: - `up` can fail with "requires mentioning all non-default flags", when the node was brought up with other flags earlier; - or it fails because the auth key was one-off or has expired. Re-using a key on an enrolled node is the common case, since the key is only needed for first enrolment. The role then fails a run on a node that is fine, or it silently re-enables a node that an operator took down on purpose. **Proposed:** run `up` only on `NeedsLogin` or `NoState`. For `Stopped`, either leave the node alone and report it, or run a plain `tailscale up` without the key. With either change, the key assert in `validate.yml` and in the `up` block follows the narrower condition. **Decision needed:** - (a) only `NeedsLogin`/`NoState`, and leave `Stopped` alone (recommended: the role does not override an operator's `tailscale down`); - (b) as (a), but `Stopped` gets a plain `tailscale up`; - (c) keep the current behaviour and document it. ## 2. The userspace-networking flag is matched on one spelling only `tasks/configure.yml` recognises only the exact token `--tun=userspace-networking` in `FLAGS` of `/etc/default/tailscaled`. Some spellings are neither removed when `tailscale_userspace_networking: false` nor de-duplicated when `true`: - a hand-written `-tun=userspace-networking`; - `--tun userspace-networking` (a space instead of `=`); - another `--tun=<value>`. So `FLAGS` can end up with two `--tun` flags, or keep the flag after the input was turned off. **Proposed:** treat any `-tun`/`--tun` flag (with `=` or a space) as the role's own. When `true`, replace it with `--tun=userspace-networking`; when `false`, remove it. Another `--tun=<value>` is either overwritten or refused with a message. **Decision needed:** - whether the role owns every `--tun` flag (overwrite), or refuses a foreign `--tun` value; - whether this is worth the regex at all, given that nothing but the role writes `FLAGS` on managed hosts. ## Tests - **Molecule:** for item 1, a node that is not enrolled stays at `NeedsLogin` under userspace networking, so only that path can be exercised. `Stopped` needs an enrolled node, so the state decision is tested at the task level: run with a faked `__tailscale_status` result in the refusal/assert style of `verify.yml`. For item 2, seed `FLAGS` with each spelling in `verify.yml`, then assert the result for `true` and for `false`. - **Semver:** a behaviour change, so `minor_changes` (`breaking_changes` if option 1a is called breaking). Depends on #398. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added the Kind/Enhancement
Status
Needs Triage
labels 2026-11-26 21:14:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#403