From 453fa4c16c36952bdb6507338ded276be454ba1d Mon Sep 17 00:00:00 2001 From: ChaosZero112 Date: Sat, 15 Jun 2019 13:00:59 -0400 Subject: [PATCH] Initial qbittorrent-vpn commit --- apps/qbittorrent-vpn.yml | 292 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 apps/qbittorrent-vpn.yml diff --git a/apps/qbittorrent-vpn.yml b/apps/qbittorrent-vpn.yml new file mode 100644 index 0000000..edb0d85 --- /dev/null +++ b/apps/qbittorrent-vpn.yml @@ -0,0 +1,292 @@ +#!/bin/bash +# +# Title: qBittorrent (with OpenVPN and Privoxy) +# Author(s): Mike Tzou (Chocobo1), Vladimir Golovnev (glassez), Diego Heras (ngosang), binhex +# URL: https://www.qbittorrent.org/ - https://github.com/binhex/arch-qbittorrentvpn +# GNU: General Public License v2.0 (w/ exception) +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + + - name: 'Set Known Facts' + set_fact: + pgrole: 'qbittorrent' + intport: '8998' + extport: '8998' + intport1: '8118' + extport1: '8118' + intport2: '6881' + extport2: '6881' + dnsserver1: '1.1.1.1' + dnsserver2: '84.200.69.80' + dnsserver3: '37.235.1.174' + dnsserver4: '185.121.177.177' + image: 'binhex/arch-qbittorrentvpn:latest' + + # CORE (MANDATORY) ############################################################# + - name: 'Including cron job' + include_tasks: '/opt/coreapps/apps/_core.yml' + + - name: 'Including folders' + include_tasks: '/opt/coreapps/apps/_downloaders.yml' + + - name: 'Including plugins' + include_tasks: '/opt/coreapps/apps/_plugins.yml' + + # LABELS ###################################################################### + - name: 'Adding Traefik' + set_fact: + pg_labels: + traefik.frontend.auth.forward.address: '{{gauth}}' + traefik.enable: 'true' + traefik.port: '{{intport}}' + traefik.frontend.rule: 'Host:{{pgrole}}.{{domain.stdout}},{{tldset}}' + + - name: 'Setting PG Volumes' + set_fact: + pg_volumes: + - '/etc/localtime:/etc/localtime:ro' + - '/opt/appdata/{{pgrole}}:/config' + - '{{path.stdout}}:{{path.stdout}}' + - '/mnt:/mnt' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: '1000' + PGID: '1000' + UMASK: '000' + VPN_ENABLED: 'no' + VPN_USER: 'username' + VPN_PASS: 'password' + VPN_PROV: 'custom' + VPN_OPTIONS: '--inactive 3600 --ping 10 --ping-exit 60' + STRICT_PORT_FORWARD: 'no' + ENABLE_PRIVOXY: 'no' + LAN_NETWORK: '127.20.0.0/16' + NAME_SERVERS: '{{dnsserver1}},{{dnsserver2}},{{dnsserver3}},{{dnsserver4}}' + DEBUG: 'false' + WEBUI_PORT: '{{intport}}' + + + + + # MAIN DEPLOYMENT ############################################################# + - name: 'Checking for existing app data' + stat: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + register: confcheck + + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + devices: + - '/dev/net/tun:/dev/net/tun:rwm' + dns_servers: + - '{{dnsserver1}}' + - '{{dnsserver2}}' + - '{{dnsserver3}}' + - '{{dnsserver4}}' + capabilities: + - NET_ADMIN + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' + + # CONFIGURATION #################################################### + - name: 'Waiting for {{pgrole}} to initialize' + wait_for: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + state: present + timeout: 15 + delay: 5 + + - name: 'Stopping {{pgrole}}' + docker_container: + name: '{{pgrole}}' + state: stopped + + - name: Set SavePath + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Downloads\SavePath + value: '{{path.stdout}}/downloads/{{pgrole}}' + state: present + + + - name: Set TempPathEnabled + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Downloads\TempPathEnabled + value: True + state: present + + # FIRST TIME CONFIGURATION #################################################### + - name: 'Configuring {{pgrole}} for first time use' + block: + - name: Enable AutoRun + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: AutoRun + option: enabled + value: True + state: present + + - name: Enable Auto UnRar + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: AutoRun + option: program + value: '/usr/bin/unrar x -r \"%F/.\" \"%F/\"' + state: present + + - name: Disable DHT + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\DHT + value: false + state: present + + - name: Disable PeX + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\PeX + value: false + state: present + + - name: Disable LSD + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\LSD + value: false + state: present + + - name: Enable Encryption + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\Encryption + value: 1 + state: present + + - name: Don't use incomplete extension + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Downloads\UseIncompleteExtension + value: false + state: present + - name: Ignore slow torrents + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Queueing\IgnoreSlowTorrents + value: True + state: present + - name: Set MaxActiveDownloads + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Queueing\MaxActiveDownloads + value: 10 + state: present + - name: Set MaxActiveTorrents + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Queueing\MaxActiveTorrents + value: 100 + state: present + - name: Set MaxActiveUploads + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Queueing\MaxActiveUploads + value: 100 + state: present + - name: Set GlobalMaxSeedingMinutes + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: BitTorrent + option: Session\GlobalMaxSeedingMinutes + value: 20160 + state: present + - name: Set MaxRatio + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\MaxRatio + value: 1 + state: present + - name: pause on MaxRatioAction + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: Bittorrent\MaxRatioAction + value: 1 + state: present + - name: Disable csrf + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: WebUI\CSRFProtection + value: false + force: yes + state: present + - name: Disable HostHeaderValidation + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: WebUI\HostHeaderValidation + value: false + force: yes + state: present + - name: Disable ClickjackingProtection + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: WebUI\ClickjackingProtection + value: false + force: yes + state: present + + - name: Set ServerDomains + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: WebUI\ServerDomains + value: '*' + force: yes + state: present + - name: Set Address + ini_file: + path: '/opt/appdata/{{pgrole}}/qBittorrent/qBittorrent.conf' + section: Preferences + option: WebUI\Address + value: '*' + force: yes + state: present + + when: not confcheck.stat.exists + - name: Restart {{pgrole}} + docker_container: + name: '{{pgrole}}' + state: started \ No newline at end of file