Spaces:
No application file
No application file
File size: 1,378 Bytes
53b59a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
---
- name: Tailscale Setup
hosts: all
become: yes
vars_files:
- vars/secrets.yml
tasks:
- name: Check if Tailscale GPG key exists
stat:
path: /usr/share/keyrings/tailscale-archive-keyring.gpg
register: tailscale_key
- name: Download Tailscale GPG key
get_url:
url: https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg
dest: /usr/share/keyrings/tailscale-archive-keyring.gpg
mode: '0644'
when: not tailscale_key.stat.exists
- name: Add Tailscale repository
ansible.builtin.apt_repository:
repo: deb [signed-by=/usr/share/keyrings/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/ubuntu jammy main
state: present
filename: tailscale
- name: Update apt cache again
apt:
update_cache: yes
- name: Install Tailscale
apt:
name: tailscale
state: present
- name: Check Tailscale status
command: tailscale status
register: tailscale_status
changed_when: false
ignore_errors: yes
- name: Run tailscale up with pre-authentication
command: tailscale up --authkey={{ tailscale_authkey }}
register: tailscale_result
changed_when: "'Success' in tailscale_result.stdout"
when: tailscale_status.rc != 0 or 'Tailscale is stopped' in tailscale_status.stdout
|