2026-01-15 20:55:25 -08:00
|
|
|
---
|
|
|
|
|
- name: Get current tailscale serve status
|
|
|
|
|
ansible.builtin.command: tailscale serve status --json
|
2026-01-16 19:33:02 -08:00
|
|
|
register: tailscale_serve_status
|
2026-01-15 20:55:25 -08:00
|
|
|
changed_when: false
|
|
|
|
|
|
2026-01-16 12:30:20 -08:00
|
|
|
- name: Parse serve status
|
|
|
|
|
ansible.builtin.set_fact:
|
2026-01-16 19:33:02 -08:00
|
|
|
tailscale_serve_config: "{{ ((tailscale_serve_status.stdout | default('{}', true)) | from_json).Services | default({}) }}"
|
2026-01-16 12:30:20 -08:00
|
|
|
|
|
|
|
|
# Configure HTTPS if service doesn't have Web config yet
|
2026-01-15 20:55:25 -08:00
|
|
|
- name: Configure HTTPS services
|
|
|
|
|
ansible.builtin.command: >
|
|
|
|
|
tailscale serve --service="{{ item.name }}"
|
|
|
|
|
--https={{ item.https.port }} {{ item.https.upstream }}
|
2026-01-16 19:33:02 -08:00
|
|
|
loop: "{{ tailscale_serve_services }}"
|
2026-01-16 12:30:20 -08:00
|
|
|
when:
|
|
|
|
|
- item.https is defined
|
2026-01-16 19:33:02 -08:00
|
|
|
- tailscale_serve_config[item.name] is not defined or tailscale_serve_config[item.name].Web is not defined
|
|
|
|
|
register: tailscale_serve_https_result
|
|
|
|
|
changed_when: true
|
2026-01-15 20:55:25 -08:00
|
|
|
failed_when: false
|
|
|
|
|
|
2026-01-16 12:30:20 -08:00
|
|
|
# Configure TCP if service doesn't have the specific port configured yet
|
2026-01-15 20:55:25 -08:00
|
|
|
- name: Configure TCP services
|
|
|
|
|
ansible.builtin.command: >
|
|
|
|
|
tailscale serve --service="{{ item.name }}"
|
|
|
|
|
--tcp={{ item.tcp.port }} {{ item.tcp.upstream }}
|
2026-01-16 19:33:02 -08:00
|
|
|
loop: "{{ tailscale_serve_services }}"
|
2026-01-16 12:30:20 -08:00
|
|
|
when:
|
|
|
|
|
- item.tcp is defined
|
2026-01-16 19:33:02 -08:00
|
|
|
- tailscale_serve_config[item.name] is not defined or
|
|
|
|
|
tailscale_serve_config[item.name].TCP is not defined or
|
|
|
|
|
tailscale_serve_config[item.name].TCP[item.tcp.port | string] is not defined or
|
|
|
|
|
tailscale_serve_config[item.name].TCP[item.tcp.port | string].TCPForward is not defined
|
|
|
|
|
register: tailscale_serve_tcp_result
|
|
|
|
|
changed_when: true
|
2026-01-15 20:55:25 -08:00
|
|
|
failed_when: false
|