-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployTdarr.yml
154 lines (150 loc) · 4.55 KB
/
deployTdarr.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
- name: Deploy Tdarr
hosts: test
tasks:
- name: Install Autofs and Docker-Compose
apt:
pkg:
- autofs
- docker-compose
# Fuse is a dependency for rclone.
- fuse
# Curl and unzip are dependencies for rclone setup.
- curl
- unzip
update_cache: yes
become: true
- name: Ensures /home/bears/gdrive/ dir exists
file: path=/home/bears/gdrive/ state=directory
become: true
# WIREGUARD
# This section only runs when the wg var is defined.
- name: get current kernel, we need this to install wireguard linux-headers
ansible.builtin.shell: uname -r
register: result
- name: Install Wireguard
apt:
pkg:
- linux-headers-{{ result.stdout }}
- wireguard
- resolvconf
become: true
when: wg is defined
- name: Configure Wireguard
ansible.builtin.template:
src: "{{ wg_file }}.conf"
dest: /etc/wireguard/
become: true
when: wg is defined
- name: wg-quick setup
ansible.builtin.shell: "wg-quick up {{ wg_file }}"
ignore_errors: true # This suboptimally solves an error that crops up when a wireguard interface is already defined.
when: wg is defined
# AUTOFS
- name: Add our auto.nfs file to autofs master
ansible.builtin.lineinfile:
dest: /etc/auto.master
line: "/- /etc/auto.nfs"
regexp: "/- /etc/auto.nfs"
become: true
- name: Create our auto.nfs file
ansible.builtin.lineinfile:
dest: /etc/auto.nfs
create: yes
line: "/data 192.168.8.83:/data"
regexp: "^/data"
become: true
- name: Restart autofs
ansible.builtin.systemd:
state: restarted
daemon_reload: yes
enabled: yes
name: autofs
become: true
# RCLONE
# Note: This will not update rclone
- name: Check is rclone is already installed
stat:
path: /usr/bin/rclone
register: rclone_result
- name: Install Rclone if it isn't already
ansible.builtin.shell: "curl https://rclone.org/install.sh | bash"
become: true
when: not rclone_result.stat.exists
- name: Ensures /root/.config/rclone/ dir exists
file: path=/root/.config/rclone/ state=directory
become: true
- name: Configure Rclone
ansible.builtin.copy:
src: rclone.conf
dest: /root/.config/rclone/rclone.conf
become: true
- name: Ensure gdrive folder exists
file: path=~/gdrive state=directory
- name: Check is rclone is already aliased.
stat:
path: /sbin/mount.rclone
register: stat_result
- name: Link rclone to systemd
ansible.builtin.shell: "ln -s /usr/bin/rclone /sbin/mount.rclone"
when: not stat_result.stat.exists
become: true
- name: Copy mount to systemd
ansible.builtin.copy:
src: home-bears-gdrive.mount
dest: /etc/systemd/system/
become: true
- name: Copy automount to systemd
ansible.builtin.copy:
src: home-bears-gdrive.automount
dest: /etc/systemd/system/
become: true
- name: Make sure gdrive gets started
ansible.builtin.systemd:
state: started
daemon_reload: yes
enabled: yes
name: home-bears-gdrive.mount
become: true
- name: Make sure gdrive.automount gets started
ansible.builtin.systemd:
daemon_reload: yes
enabled: yes
name: home-bears-gdrive.automount
become: true
# DOCKER
- name: Add user to docker group
ansible.builtin.user:
name: ansible_ssh_user
groups: docker
become: true
- name: Make sure docker is running
ansible.builtin.systemd:
state: restarted
daemon_reload: yes
enabled: yes
name: docker
become: true
- name: Make sure docker.socket is running
ansible.builtin.systemd:
state: restarted
daemon_reload: yes
enabled: yes
name: docker.socket
become: true
- name: Ensure Tdarrs configs may be stored
file: path=/docker/tdarr/configs/ state=directory
become: true
- name: Ensure Tdarrs logs may be stored
file: path=/docker/tdarr/logs/ state=directory
become: true
- name: Create compose script from template
ansible.builtin.template:
src: docker-compose.jn2
dest: /home/bears/docker-compose.yml
become: true
- name: Docker-Compose Pull
community.docker.docker_compose:
pull: yes
project_src: /home/bears
become: true