From 0e5e3cca90d4a63b48134aa5329002ef6a66441a Mon Sep 17 00:00:00 2001 From: sneedster Date: Sat, 12 Jan 2019 11:13:01 -0800 Subject: [PATCH] create delugevpn.yml I'm not sure how to code it to ask for vars like username and password for vpn, but I figure I can change those from within portainer. --- apps/delugevpn.yml | 293 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 apps/delugevpn.yml diff --git a/apps/delugevpn.yml b/apps/delugevpn.yml new file mode 100644 index 0000000..bbeadeb --- /dev/null +++ b/apps/delugevpn.yml @@ -0,0 +1,293 @@ +#!/bin/bash +# +# Title: PlexGuide (Reference Title File) +# Author(s): Admin9705 +# URL: https://plexguide.com - http://github.plexguide.com +# GNU: General Public License v3.0 +################################################################################ +--- +- hosts: localhost + gather_facts: false + tasks: + # FACTS ####################################################################### + - name: 'Set Known Facts' + set_fact: + pgrole: 'deluge' + intport: '8112' + extport: '8112' + intport2: '58846' + extport2: '58846' + intport3: '58946' + extport3: '58946' + intport4: '8118' + extport4: '8118' + image: 'binhex/arch-delugevpn' + + # CORE (MANDATORY) ############################################################ + - name: 'Including cron job' + include_tasks: '/opt/plexguide/containers/_core.yml' + + # FOLDER CREATION ############################################################# + - name: 'Including folders' + include_tasks: '/opt/plexguide/containers/_folders.yml' + + - name: 'Checking for existing app data' + stat: + path: /opt/appdata/{{pgrole}}/core.conf + register: confcheck + + # 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: + - '/opt/appdata/{{pgrole}}:/config' + - '{{path.stdout}}:{{path.stdout}}' + - '/etc/localtime:/etc/localtime:ro' + - '/mnt:/mnt' + + - name: 'Setting PG ENV' + set_fact: + pg_env: + PUID: 1000 + PGID: 1000 + VPN_ENABLED: yes + VPN_USER: vpnuser + VPN_PASS: vpnpass + VPN_PROV: vpnprov + ENABLE_PRIVOXY: no + STRICT_PORT_FORWARD: no + LAN_NETWORK: 192.168.1.1/24 + + # MAIN DEPLOYMENT ############################################################# + - name: 'Deploying {{pgrole}}' + docker_container: + name: '{{pgrole}}' + image: '{{image}}' + pull: yes + published_ports: + - '{{ports.stdout}}{{extport}}:{{intport}}' + - '{{ports.stdout}}{{extport2}}:{{intport2}}' + - '{{ports.stdout}}{{extport3}}:{{intport3}}' + - '{{ports.stdout}}{{extport4}}:{{intport4}}' + volumes: '{{pg_volumes}}' + env: '{{pg_env}}' + restart_policy: unless-stopped + networks: + - name: plexguide + aliases: + - '{{pgrole}}' + state: started + labels: '{{pg_labels}}' + + # CONFIGURATION ########################################################### + - name: 'Waiting for {{pgrole}} to initialize' + wait_for: + timeout: 10 + + - name: Stopping {{pgrole}} + docker_container: + name: '{{pgrole}}' + state: stopped + + - name: 'Checking for appdata' + wait_for: + path: '/opt/appdata/{{pgrole}}/core.conf' + state: present + + - name: Setting plugins directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"plugins_location".*' + line: '"plugins_location": "/config/plugins",' + state: present + + - name: Set download location + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"download_location".*' + line: '"download_location": "{{path.stdout}}/downloads/{{pgrole}}",' + state: present + when: incomplete.stdout | length == 0 + + - name: Set incomplete path + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"download_location".*' + line: '"download_location": "{{path.stdout}}/incomplete/{{pgrole}}",' + state: present + when: incomplete.stdout | length > 0 + + - name: Setting complete downloads directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"move_completed_path".*' + line: '"move_completed_path": "{{path.stdout}}/downloads/{{pgrole}}",' + state: present + when: incomplete.stdout | length > 0 + + - name: Setting torrent file directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"torrentfiles_location".*' + line: '"torrentfiles_location": "{{path.stdout}}/torrent",' + state: present + + - name: Setting torrent watch directory + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"autoadd_location".*' + line: '"autoadd_location": "{{path.stdout}}/torrent/watch",' + state: present + + - name: Setting move_completed when incomplete is undefined + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"move_completed".*' + line: '"move_completed": false,' + state: present + when: incomplete.stdout | length == 0 + + - name: Setting move_completed when incomplete is defined + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"move_completed".*' + line: '"move_completed": true,' + state: present + when: incomplete.stdout | length > 0 + + - name: Setting extractor folder + lineinfile: + path: '/opt/appdata/{{pgrole}}/plugins/extractor.conf' + regexp: '"use_name_folder".*' + line: '"use_name_folder": true,' + state: present + + - name: Setting extractor + lineinfile: + path: '/opt/appdata/{{pgrole}}/plugins/extractor.conf' + regexp: '"extract_path".*' + line: '"extract_path": "{{path.stdout}}/downloads/deluge"' + state: present + + - name: set enabled_plugins + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enabled_plugins".*' + line: '"enabled_plugins": ["Extractor", "Label"],' + state: present + + # FIRST TIME CONFIGURATION #################################################### + - name: 'Configuring {{pgrole}} for first time use' + block: + - name: set compact_allocation + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"compact_allocation".*' + line: '"compact_allocation": true,' + state: present + + - name: set stop_seed_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"stop_seed_ratio"".*' + line: '"stop_seed_ratio": 1.0,' + state: present + + - name: set share_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"share_ratio_limit".*' + line: '"share_ratio_limit": 1.0,' + state: present + + - name: set remove_seed_at_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"remove_seed_at_ratio".*' + line: '"remove_seed_at_ratio": true,' + state: present + + - name: set enc_prefer_rc4 + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_prefer_rc4".*' + line: '"enc_prefer_rc4": true,' + state: present + + - name: set enc_level + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_level".*' + line: '"enc_level": 1,' + state: present + + - name: set enc_in_policy + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_in_policy".*' + line: '"enc_in_policy": 1,' + state: present + + - name: set enc_out_policy + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enc_out_policy".*' + line: '"enc_out_policy": 1,' + state: present + + - name: set max_active_downloading + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"max_active_downloading".*' + line: '"max_active_downloading": 4,' + state: present + + - name: set dont_count_slow_torrents + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"dont_count_slow_torrents".*' + line: '"dont_count_slow_torrents": true,' + state: present + + - name: set max_active_seeding + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"enabled_plugins".*' + line: '"max_active_seeding": 8,' + state: present + + - name: set share_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"share_ratio_limit".*' + line: '"share_ratio_limit": 1,' + state: present + + - name: set stop_seed_at_ratio + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"stop_seed_at_ratio".*' + line: '"stop_seed_at_ratio": 1.0,' + state: present + + - name: set seed_time_ratio_limit + lineinfile: + path: '/opt/appdata/{{pgrole}}/core.conf' + regexp: '"seed_time_ratio_limit".*' + line: '"seed_time_ratio_limit": 1.0,' + state: present + + #when: not confcheck.stat.exists + + - name: Restart {{pgrole}} + docker_container: + name: '{{pgrole}}' + state: started