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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# https://tailscale.com/download/linux/debian-bookworm
- name: Install Tailscale
tags: tailscale
hosts: "{{ ansible_limit | default([]) }}"
become: true
tasks:
- name: Assert distribution is Debian
ansible.builtin.assert:
that:
- ansible_facts["distribution"] == "Debian"
fail_msg: "This playbook only supports Debian distributions"
# ansible.builtin.deb822_repository needs python-debian on the target.
- name: Install required packages
ansible.builtin.apt:
name: python3-debian
state: present
update_cache: true
# curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
- name: Download Tailscale package signing key
ansible.builtin.get_url:
url: https://pkgs.tailscale.com/stable/debian/{{ ansible_facts["distribution_release"] }}.noarmor.gpg
dest: /usr/share/keyrings/tailscale-archive-keyring.gpg
mode: "0644"
# Left behind by ansible.builtin.apt_repository; apt reads both formats, so
# leaving them would configure the repository twice. Older runs didn't set
# a filename, so match on the URI rather than tailscale.list.
- name: Find one-line Tailscale repositories
ansible.builtin.find:
paths: /etc/apt/sources.list.d
patterns: "*.list"
contains: pkgs\.tailscale\.com
read_whole_file: true
register: tailscale_list_sources
- name: Remove one-line Tailscale repositories
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ tailscale_list_sources.files }}"
loop_control:
label: "{{ item.path }}"
# curl -fsSL https://pkgs.tailscale.com/stable/debian/bookworm.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
- name: Add Tailscale repository
ansible.builtin.deb822_repository:
name: tailscale
types: deb
uris: https://pkgs.tailscale.com/stable/debian
suites: '{{ ansible_facts["distribution_release"] }}'
components: main
signed_by: /usr/share/keyrings/tailscale-archive-keyring.gpg
state: present
# sudo apt-get update
# sudo apt-get install tailscale
- name: Install Tailscale
ansible.builtin.apt:
name: tailscale
state: present
update_cache: true
# - name: Restrict tailscaled logging
# hosts: "{{ ansible_limit | default([]) }}"
# become: true
# tasks:
#
# - name: Create systemd override dir for tailscaled
# ansible.builtin.file:
# path: /etc/systemd/system/tailscaled.service.d
# state: directory
# mode: "0644"
#
# - name: Create systemd override
# ansible.builtin.copy:
# content: |
# [Service]
# LogLevelMax=notice
# dest: /etc/systemd/system/tailscaled.service.d/override.conf
# mode: "0644"
# notify:
# - Restart Tailscale
handlers:
- name: Restart Tailscale
ansible.builtin.systemd:
name: tailscaled
state: restarted
daemon_reload: true
# vim: ft=yaml.ansible