From 5d9ee7190d1dde2e6c49373bfd963002f74e6568 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 16 Apr 2021 21:49:00 +0100 Subject: [PATCH] Swap out deluge for qbittorrent Just run on arch instead of docker, too. Much simpler. --- ansible/group_vars/all/pve.yml | 4 +- ansible/hosts | 2 +- ansible/main.yml | 7 ++- ansible/roles/deluge/files/docker-compose.yml | 24 ---------- ansible/roles/deluge/handlers/main.yml | 4 -- ansible/roles/deluge/tasks/main.yml | 17 ------- ansible/roles/qbittorrent/files/nginx.conf | 29 +++++++++++ ansible/roles/qbittorrent/handlers/main.yml | 11 +++++ ansible/roles/qbittorrent/tasks/main.yml | 5 ++ ansible/roles/qbittorrent/tasks/nginx.yml | 18 +++++++ .../roles/qbittorrent/tasks/qbittorrent.yml | 48 +++++++++++++++++++ 11 files changed, 117 insertions(+), 52 deletions(-) delete mode 100644 ansible/roles/deluge/files/docker-compose.yml delete mode 100644 ansible/roles/deluge/handlers/main.yml delete mode 100644 ansible/roles/deluge/tasks/main.yml create mode 100644 ansible/roles/qbittorrent/files/nginx.conf create mode 100644 ansible/roles/qbittorrent/handlers/main.yml create mode 100644 ansible/roles/qbittorrent/tasks/main.yml create mode 100644 ansible/roles/qbittorrent/tasks/nginx.yml create mode 100644 ansible/roles/qbittorrent/tasks/qbittorrent.yml diff --git a/ansible/group_vars/all/pve.yml b/ansible/group_vars/all/pve.yml index f7e6676..a20eb1e 100644 --- a/ansible/group_vars/all/pve.yml +++ b/ansible/group_vars/all/pve.yml @@ -10,8 +10,8 @@ pve_hosts: ip: 192.168.1.132 forrest: ip: 10.23.1.99 - deluge: - ip: 10.23.1.52 pve: ip: 10.23.1.1 external_ip: 192.168.2.200 + qbittorrent: + ip: 10.23.1.21 diff --git a/ansible/hosts b/ansible/hosts index 4c49234..f0fed82 100644 --- a/ansible/hosts +++ b/ansible/hosts @@ -8,4 +8,4 @@ ingress pve-docker jellyfin forrest -deluge +qbittorrent diff --git a/ansible/main.yml b/ansible/main.yml index 8c719ba..1210905 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -15,7 +15,7 @@ - casey - grimes - ingress - - deluge + - qbittorrent roles: - role: geerlingguy.ntp become: true @@ -27,7 +27,6 @@ - hosts: - grimes - pve-docker - - deluge - forrest roles: - role: geerlingguy.docker @@ -85,6 +84,6 @@ - forrest - pve_nebula_route -- hosts: deluge +- hosts: qbittorrent roles: - - deluge + - qbittorrent diff --git a/ansible/roles/deluge/files/docker-compose.yml b/ansible/roles/deluge/files/docker-compose.yml deleted file mode 100644 index 6056caa..0000000 --- a/ansible/roles/deluge/files/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: "2.3" - -services: - deluge: - image: linuxserver/deluge:latest - network_mode: host - environment: - - PUID={{ docker_user.id }} - - PGID={{ docker_user.id }} - - TZ={{ TZ }} - volumes: - - ./deluge:/config - - /mnt/downloads:/downloads - restart: unless-stopped - - egress: - image: theorangeone/static-server:latest - restart: unless-stopped - environment: - - INDEX=on - volumes: - - /mnt/downloads:/srv:ro - ports: - - 80:80 diff --git a/ansible/roles/deluge/handlers/main.yml b/ansible/roles/deluge/handlers/main.yml deleted file mode 100644 index 7bd8472..0000000 --- a/ansible/roles/deluge/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: restart deluge - shell: - chdir: /opt/deluge - cmd: "{{ docker_update_command }}" diff --git a/ansible/roles/deluge/tasks/main.yml b/ansible/roles/deluge/tasks/main.yml deleted file mode 100644 index 1cbc715..0000000 --- a/ansible/roles/deluge/tasks/main.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Create deluge directory - file: - path: /opt/deluge - state: directory - owner: "{{ docker_user.name }}" - mode: "{{ docker_compose_directory_mask }}" - become: true - -- name: Install deluge compose file - template: - src: files/docker-compose.yml - dest: /opt/deluge/docker-compose.yml - mode: "{{ docker_compose_file_mask }}" - owner: "{{ docker_user.name }}" - validate: docker-compose -f %s config - notify: restart deluge - become: true diff --git a/ansible/roles/qbittorrent/files/nginx.conf b/ansible/roles/qbittorrent/files/nginx.conf new file mode 100644 index 0000000..d309761 --- /dev/null +++ b/ansible/roles/qbittorrent/files/nginx.conf @@ -0,0 +1,29 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + tcp_nopush on; + + keepalive_timeout 65; + + gzip on; + + server { + listen 80; + + root /mnt/downloads; + + gzip_static off; + gzip_types *; + + autoindex on; + autoindex_exact_size off; + } +} diff --git a/ansible/roles/qbittorrent/handlers/main.yml b/ansible/roles/qbittorrent/handlers/main.yml new file mode 100644 index 0000000..1350833 --- /dev/null +++ b/ansible/roles/qbittorrent/handlers/main.yml @@ -0,0 +1,11 @@ +- name: restart nginx + service: + name: nginx + state: restarted + become: true + +- name: restart qbittorrent + service: + name: qbittorrent-nox@{{ qbittorrent_user.name }} + state: restarted + become: true diff --git a/ansible/roles/qbittorrent/tasks/main.yml b/ansible/roles/qbittorrent/tasks/main.yml new file mode 100644 index 0000000..d7faa19 --- /dev/null +++ b/ansible/roles/qbittorrent/tasks/main.yml @@ -0,0 +1,5 @@ +- name: qbittorrent + include: qbittorrent.yml + +- name: nginx + include: nginx.yml diff --git a/ansible/roles/qbittorrent/tasks/nginx.yml b/ansible/roles/qbittorrent/tasks/nginx.yml new file mode 100644 index 0000000..f8c8373 --- /dev/null +++ b/ansible/roles/qbittorrent/tasks/nginx.yml @@ -0,0 +1,18 @@ +- name: Install nginx + package: + name: nginx + become: true + +- name: Enable nginx + service: + name: nginx + enabled: true + become: true + +- name: Nginx config + template: + src: files/nginx.conf + dest: /etc/nginx/nginx.conf + mode: "0600" + become: true + notify: restart nginx diff --git a/ansible/roles/qbittorrent/tasks/qbittorrent.yml b/ansible/roles/qbittorrent/tasks/qbittorrent.yml new file mode 100644 index 0000000..1c6fed0 --- /dev/null +++ b/ansible/roles/qbittorrent/tasks/qbittorrent.yml @@ -0,0 +1,48 @@ +- name: Install qbittorrent + package: + name: qbittorrent-nox + become: true + +- name: Create user + user: + name: qbittorrent + system: true + become: true + register: qbittorrent_user + +- name: Enable service + service: + name: qbittorrent-nox@{{ qbittorrent_user.name }} + enabled: true + become: true + +- name: Set configuration + ini_file: + path: "{{ qbittorrent_user.home }}/.config/qBittorrent/qBittorrent.conf" + mode: 0700 + owner: "{{ qbittorrent_user.name }}" + section: "{{ item.section }}" + option: "{{ item.option }}" + value: "{{ item.value }}" + no_extra_spaces: true + loop_control: + label: "{{ item.section }}.{{ item.option }}={{ item.value }}" + loop: + - {section: AutoRun, option: enabled, value: "false"} + - {section: LegalNotice, option: Accepted, value: "true"} + - {section: Preferences, option: Connection\UPnP, value: "false"} + - {section: Preferences, option: Downloads\SavePath, value: /mnt/downloads/completed/} + - {section: Preferences, option: Downloads\TempPath, value: /mnt/downloads/} + - {section: Preferences, option: Downloads\TempPathEnabled, value: "true"} + - {section: Preferences, option: WebUI\Address, value: "*"} + - {section: Preferences, option: WebUI\ServerDomains, value: "*"} + - {section: Preferences, option: WebUI\Port, value: "8080"} + - {section: Preferences, option: WebUI\AuthSubnetWhitelist, value: 0.0.0.0/0} + - {section: Preferences, option: WebUI\AuthSubnetWhitelistEnabled, value: "true"} + - {section: Preferences, option: WebUI\LocalHostAuth, value: "false"} + - {section: Preferences, option: Bittorrent\MaxConnecs, value: -1"} + - {section: Preferences, option: Bittorrent\MaxConnecsPerTorrent, value: -1"} + - {section: Preferences, option: Bittorrent\MaxUploads, value: -1"} + - {section: Preferences, option: Bittorrent\MaxUploadsPerTorrent, value: -1"} + become: true + notify: restart qbittorrent