-
Notifications
You must be signed in to change notification settings - Fork 0
/
homeserver.yml
103 lines (85 loc) · 2.92 KB
/
homeserver.yml
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
96
97
98
99
100
101
102
103
---
- name: Configure homeserver (Debian)
hosts: "*"
become: true
remote_user: sawyer
pre_tasks:
- name: install docker
ansible.builtin.include_tasks:
file: tasks/install-docker.yml
- name: Add specified repository into sources list using specified filename
when: ansible_distribution == "Debian"
ansible.builtin.apt_repository:
repo: deb http://deb.debian.org/debian/ {{ ansible_distribution_release | lower }} main contrib non-free non-free-firmware
state: present
- name: update
ansible.builtin.include_tasks:
file: tasks/apt.yml
- name: Crate docker stack dir
ansible.builtin.file:
path: /home/sawyer/compose-files/
state: directory
- name: Copy secrets file
ansible.builtin.copy:
decrypt: true
src: secrets.env
dest: /home/sawyer/compose-files
tasks:
- name: install and configure tailscale
ansible.builtin.include_tasks:
file: tasks/tailscale.yml
vars:
tailscale_hostname: homeserver
- name: install nvidia and nvidia container tools
ansible.builtin.include_tasks:
file: tasks/nvidia.yml
- name: Copy compose files
ansible.builtin.copy:
src: docker
dest: /home/sawyer/compose-files
- name: Get rathole token
ansible.builtin.shell:
cat /home/sawyer/compose-files/secrets.env | grep RATHOLE_TOKEN | sed 's/^.*RATHOLE_TOKEN=//'
register: rathole_token
ignore_errors: true
changed_when: false
- name: Replace rathole tokens with secret
ansible.builtin.replace:
path: /home/sawyer/compose-files/docker/rathole/rathole.toml
regexp: '"token"'
replace: '"{{ rathole_token.stdout }}"'
- name: Get cf email
ansible.builtin.shell:
cat /home/sawyer/compose-files/secrets.env | grep CF_API_EMAIL | sed 's/^.*CF_API_EMAIL=//'
register: cf_email
ignore_errors: true
changed_when: false
- name: Replace cf_email with email
ansible.builtin.replace:
path: /home/sawyer/compose-files/docker/traefik/static.toml
regexp: '"email"'
replace: '"{{ cf_email.stdout }}"'
- name: Create 'web' network
community.docker.docker_network:
name: web
- name: Create 'internal' network
community.docker.docker_network:
name: internal
- name: reboot if needed
ansible.builtin.include_tasks:
file: tasks/reboot.yml
- name: install cif utils
apt:
name:
- cifs-utils
- name: Create acme dir
ansible.builtin.file:
path: /home/sawyer/acme/
state: "directory"
mode: '0600'
- name: Setup containers
community.docker.docker_compose_v2:
project_name: homeserver
env_files: /home/sawyer/compose-files/secrets.env
project_src: ./
files: /home/sawyer/compose-files/docker/compose.yml