48 lines
No EOL
1.6 KiB
YAML
48 lines
No EOL
1.6 KiB
YAML
---
|
|
- name: Install Tailscale on K3s control plane
|
|
hosts: k3s_server
|
|
become: true
|
|
roles:
|
|
- role: artis3n.tailscale
|
|
vars:
|
|
# Pull Tailscale auth key from environment variable
|
|
tailscale_authkey: "{{ lookup('ansible.builtin.env', 'TAILSCALE_KEY') }}"
|
|
tailscale_args: "--ssh"
|
|
pre_tasks:
|
|
- name: Debug - Check Tailscale key (will be partially redacted)
|
|
debug:
|
|
msg:
|
|
- "Key exists: {{ 'TAILSCALE_KEY' in ansible_env }}"
|
|
- "Key length: {{ lookup('ansible.builtin.env', 'TAILSCALE_KEY') | length }}"
|
|
- "Key prefix: {{ lookup('ansible.builtin.env', 'TAILSCALE_KEY')[0:10] }}..."
|
|
when: lookup('ansible.builtin.env', 'TAILSCALE_KEY') | length > 0
|
|
|
|
- name: Fail if no Tailscale key
|
|
fail:
|
|
msg: "TAILSCALE_KEY environment variable is not set!"
|
|
when: lookup('ansible.builtin.env', 'TAILSCALE_KEY') | length == 0
|
|
|
|
- name: Ensure artis3n.tailscale role is installed
|
|
delegate_to: localhost
|
|
become: false
|
|
ansible.builtin.command:
|
|
cmd: ansible-galaxy install artis3n.tailscale
|
|
run_once: true
|
|
|
|
post_tasks:
|
|
- name: Wait for Tailscale to be connected
|
|
ansible.builtin.command:
|
|
cmd: tailscale status
|
|
register: tailscale_status
|
|
until: '"100.64" in tailscale_status.stdout'
|
|
retries: 10
|
|
delay: 5
|
|
|
|
- name: Get Tailscale IP
|
|
ansible.builtin.command:
|
|
cmd: tailscale ip -4
|
|
register: tailscale_ip
|
|
|
|
- name: Display Tailscale IP
|
|
debug:
|
|
msg: "{{ inventory_hostname }} Tailscale IP: {{ tailscale_ip.stdout }}" |