-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathqbittorrent.yml
208 lines (180 loc) · 7.65 KB
/
qbittorrent.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
- hosts: homelab
vars:
application: qbittorrent
docker_network: "{{ networks.pub }}"
handlers:
- name: Restart
community.docker.docker_container:
name: "{{ application }}"
restart: true
comparisons:
'*': ignore
tasks:
- name: Create config folder
ansible.builtin.file:
path: "{{ config_directory }}"
state: directory
owner: "{{ common_user }}"
group: "{{ common_root_group }}"
mode: "0771"
- name: Create container
ansible.builtin.include_role:
name: docker_container
vars:
image: lscr.io/linuxserver/qbittorrent:4.6.7
env:
PUID: "{{ common_user_id | string }}"
PGID: "{{ common_root_group | string }}"
TZ: "{{ common_timezone }}"
UMASK: "022"
WEBUI_PORT: "8090"
volumes:
- "{{ config_directory }}:/config/qBittorrent"
- "{{ common_directory_download }}:{{ common_mounted_directory_download }}"
ipv4_address: "{{ docker_network.prefix }}.252"
traefik:
-
port: 8090
auth: page
rule: Host(`{{ application }}.{{ common_tld }}`)
-
name: "{{ application }}-bypass-auth"
port: 8090
rule: Host(`{{ application }}.{{ common_tld }}`) && Header(`{{ traefik_bypass_auth_header.key }}`, `{{ traefik_bypass_auth_header.value }}`)
homepage:
name: qBittorrent
group: Favourites
weight: 250
description: "Download torrents"
widget:
username: ""
password: ""
- name: Wait for config
ansible.builtin.wait_for:
path: "{{ config_directory }}/qBittorrent.conf"
register: _config_file
- name: Check if config changes required
community.general.ini_file:
path: "{{ _config_file.path }}"
section: "{{ item.key.split('.')[0] }}"
option: "{{ item.key.split('.')[1] }}"
value: "{{ item.value }}"
no_extra_spaces: true
mode: "0770"
loop: "{{ qbittorrent_config | dict2items }}"
check_mode: true
register: _qbittorrent_config
vars:
qbittorrent_config:
# Downloads
## When adding a torrent
Core.AutoDeleteAddedTorrentFile: "IfAdded" # Delete .torrent files afterwards
## Saving Management
BitTorrent.Session\DisableAutoTMMByDefault: "false" # Default Torrent Management Mode
BitTorrent.Session\DisableAutoTMMTriggers\DefaultSavePathChanged: "false" # When Default Save Path changed:
BitTorrent.Session\DisableAutoTMMTriggers\CategorySavePathChanged: "false" # When Category Save Path changed
BitTorrent.Session\DefaultSavePath: "{{ common_mounted_directory_download }}" # Default Save Path
# Run external program on torrent completion
AutoRun.enabled: "true"
AutoRun.program: chmod -R 770 \"%F/\" # Run external program on torrent finished
AutoRun.OnTorrentAdded\Enabled: "false"
AutoRun.OnTorrentAdded\Program: ""
# Connections
BitTorrent.Session\BTProtocol: TCP # Peer connection protocol
## Listening Port
BitTorrent.Session\Port: 34727 # Port used for incoming connections
## Connection Limits
BitTorrent.Session\MaxConnections: -1 # Global maximum number of connections
BitTorrent.Session\MaxConnectionsPerTorrent: -1 # Maximum number of connections per torrent
BitTorrent.Session\MaxUploads: -1 # Global maximum number of upload slots
BitTorrent.Session\MaxUploadsPerTorrent: -1 # Maximum number of upload slots per torrent
# Speed
## Global Rate Limits
BitTorrent.Session\GlobalUPSpeedLimit: 200 # Upload
## Alternative Rate Limits
BitTorrent.Session\AlternativeGlobalUPSpeedLimit: 0 # Upload
BitTorrent.Session\AlternativeGlobalDLSpeedLimit: 0 # Download
# BitTorrent
## Torrent Queueing
BitTorrent.Session\MaxActiveDownloads: 20 # Maximum active downloads
BitTorrent.Session\MaxActiveUploads: 0 # Maximum active uploads
BitTorrent.Session\MaxActiveTorrents: 20 # Maximum active torrents
## Seeding Limits
BitTorrent.Session\GlobalMaxRatio: -1 # When ratio reaches
BitTorrent.Session\GlobalMaxSeedingMinutes: 5000 # When total seeding time reaches
BitTorrent.Session\GlobalMaxInactiveSeedingMinutes: -1 # When inactive seeding time reaches
Preferences.Bittorrent\MaxRatioAction: 0 # then
# Web UI
## Language
Preferences.General\Locale: "{{ common_locale | regex_replace('-', '_') }}"
## Web User Interface (Remote Control)
Preferences.WebUI\UseUPnP: "false" # Use UPnP / NAT-PMP to forward the port from my router
## Authentication
Preferences.WebUI\AuthSubnetWhitelist: 0.0.0.0/0 # Bypass authentication for clients in whitelisted IP subnets
Preferences.WebUI\AuthSubnetWhitelistEnabled: "true" # Bypass authentication for clients in whitelisted IP subnets
## Security
Preferences.WebUI\ClickjackingProtection: "false" # Enable clickjacking protection
Preferences.WebUI\CSRFProtection: "false" # Enable Cross-Site Request Forgery (CSRF) protection
# Advanced
## qBittorrent Section
Preferences.Connection\ResolvePeerCountries: "false" # Resolve peer countries
- name: Stop to make changes
community.docker.docker_container:
name: "{{ application }}"
state: stopped
when: _qbittorrent_config.changed
- name: Configure
community.general.ini_file:
path: "{{ _config_file.path }}"
section: "{{ item.key.split('.')[0] }}"
option: "{{ item.key.split('.')[1] }}"
value: "{{ item.value }}"
no_extra_spaces: true
mode: "0770"
loop: "{{ _qbittorrent_config.results | selectattr('changed', 'equalto', true) | map(attribute='item') }}"
when: _qbittorrent_config.changed
notify: Restart
- name: Find search engines to disable
ansible.builtin.stat:
path: "{{ config_directory }}/nova3/engines/{{ item }}.py"
loop:
- eztv
- legittorrents
- limetorrents
- piratebay
- rarbg
- torlock
- torrentscsv
- zooqle
- jackett
register: _qbittorrent_search_engines
- name: Disable search engines
ansible.builtin.command: "mv '{{ item.stat.path }}' '{{ item.stat.path }}.bak'"
args:
chdir: "{{ config_directory }}/nova3/engines/"
when: item.stat.exists
changed_when: true
loop: "{{ _qbittorrent_search_engines.results }}"
notify: Restart
- name: Install Prowlarr search plugin
block:
- name: Download Prowlarr search plugin
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/swannie-eire/prowlarr-qbittorrent-plugin/main/prowlarr.py
dest: "{{ config_directory }}/nova3/engines/"
mode: "0600"
owner: "{{ common_user }}"
group: "{{ common_root_group }}"
- name: Create Prowlarr search plugin config
ansible.builtin.copy:
content: |
{
"api_key": "{{ prowlarr_api_key }}",
"tracker_first": true,
"url": "http://prowlarr.{{ docker_network.name }}:9696"
}
dest: "{{ config_directory }}/nova3/engines/prowlarr.json"
owner: "{{ common_user }}"
group: "{{ common_root_group }}"
mode: "0600"