Files
Kamino/roles/tailscale/tasks/validate.yml
T
Defame1297 80c76b16ee feat(tailscale): add the tailscale role
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
2026-11-26 19:08:25 +00:00

44 lines
1.7 KiB
YAML

---
# Input checks. Imported first in main.yml with tags: always, so a bad input fails before any
# change. The argument spec (types) runs before this file.
# The repository suite and the source list follow the host's release, read from gathered facts.
- name: Require Ubuntu
ansible.builtin.assert:
that:
- ansible_facts['distribution'] | default('') == 'Ubuntu'
fail_msg: >-
tailscale supports Ubuntu only (found: {{ ansible_facts['distribution'] | default('no gathered facts') }}).
The role reads gathered facts, so run it in a play that gathers them.
quiet: true
# Read-only, so it also runs under --check. A missing binary or a daemon that is not up counts as
# not Running.
- name: Read the Tailscale backend state before any change
become: true
ansible.builtin.command: tailscale status --json
register: __tailscale_status_before
changed_when: false
failed_when: false
check_mode: false
when: tailscale_up | bool
# tailscale up runs when the node is not Running, and a removal logs it out first, so then the
# key is needed.
- name: Require an auth key when tailscale up will run
ansible.builtin.assert:
that:
- tailscale_auth_key is defined
- tailscale_auth_key is string
- tailscale_auth_key | trim | length > 0
fail_msg: >-
tailscale_auth_key must be a non-empty string: tailscale_up is true and the node is not Running
(or tailscale_remove is true), so the role runs tailscale up. Set the key, normally from a
vaulted variable, or set tailscale_up to false.
quiet: true
when:
- tailscale_up | bool
- >-
tailscale_remove | bool
or (__tailscale_status_before.stdout | default('{}', true) | from_json).BackendState | default('NoState') != 'Running'