diff options
Diffstat (limited to 'ansible/roles/torrents')
| -rw-r--r-- | ansible/roles/torrents/tasks/main.yaml | 5 | ||||
| -rw-r--r-- | ansible/roles/torrents/tasks/setup.yaml | 79 | ||||
| -rw-r--r-- | ansible/roles/torrents/templates/settings.json.j2 | 73 |
3 files changed, 157 insertions, 0 deletions
diff --git a/ansible/roles/torrents/tasks/main.yaml b/ansible/roles/torrents/tasks/main.yaml new file mode 100644 index 0000000..806a4e3 --- /dev/null +++ b/ansible/roles/torrents/tasks/main.yaml @@ -0,0 +1,5 @@ +--- + +- name: 'Run the setup tasks' + ansible.builtin.import_tasks: 'setup.yaml' + tags: 'torrents' diff --git a/ansible/roles/torrents/tasks/setup.yaml b/ansible/roles/torrents/tasks/setup.yaml new file mode 100644 index 0000000..25f1fe8 --- /dev/null +++ b/ansible/roles/torrents/tasks/setup.yaml @@ -0,0 +1,79 @@ +--- + +- name: 'setup | Ensure required vars are set' + ansible.builtin.assert: + that: + - item | mandatory + loop: + - '{{ torrents_nas_mount_path }}' + - '{{ torrents_rpc_username }}' + - '{{ torrents_rpc_password }}' + no_log: true + +- name: 'setup | Install required pkgs' + ansible.builtin.package: + name: + - 'nfs-common' + - 'transmission-daemon' + +- name: 'setup | Stop the transmission-daemon service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'stopped' + +- name: 'setup | Create the mount dir' + ansible.builtin.file: + path: '/mnt/data' + state: 'directory' + mode: '755' + +- name: 'setup | Setup the NFS mount' + ansible.posix.mount: + src: '{{ torrents_nas_mount_path }}' + path: '/mnt/data' + state: 'mounted' + fstype: 'nfs' + +- name: 'setup | Create new user for transmission' + ansible.builtin.user: + name: 'transmission-user' + uid: 1001 + groups: 'users' + create_home: true + +- name: 'setup | Fix the service file to use our user' + ansible.builtin.lineinfile: + path: '/lib/systemd/system/transmission-daemon.service' + regexp: '^User=' + line: 'User=transmission-user' + +- name: 'setup | Reload systemd daemon' + ansible.builtin.systemd: + daemon_reload: true + +# THis is kind of a hack to force the generation of +# /home/transmission-user/.config/transmission-daemon dirs +# so that we can place our config file there. +- name: 'setup | Start the service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'started' + +# We still need to stop it to place the config file or else it will get overwritten +- name: 'setup | Stop the service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'stopped' + +- name: 'setup | Copy the transmission config' + ansible.builtin.template: + src: 'settings.json.j2' + dest: '/home/transmission-user/.config/transmission-daemon/settings.json' + owner: 'transmission-user' + mode: '644' + +- name: 'setup | Start the service' + ansible.builtin.service: + name: 'transmission-daemon' + state: 'started' + enabled: true diff --git a/ansible/roles/torrents/templates/settings.json.j2 b/ansible/roles/torrents/templates/settings.json.j2 new file mode 100644 index 0000000..cf5ea4b --- /dev/null +++ b/ansible/roles/torrents/templates/settings.json.j2 @@ -0,0 +1,73 @@ +{ + "alt-speed-down": 50, + "alt-speed-enabled": false, + "alt-speed-time-begin": 540, + "alt-speed-time-day": 127, + "alt-speed-time-enabled": false, + "alt-speed-time-end": 1020, + "alt-speed-up": 50, + "bind-address-ipv4": "0.0.0.0", + "bind-address-ipv6": "::", + "blocklist-enabled": false, + "blocklist-url": "http://www.example.com/blocklist", + "cache-size-mb": 4, + "dht-enabled": true, + "download-dir": "/mnt/data/downloads", + "download-limit": 100, + "download-limit-enabled": 0, + "download-queue-enabled": true, + "download-queue-size": 5, + "encryption": 1, + "idle-seeding-limit": 30, + "idle-seeding-limit-enabled": false, + "incomplete-dir": "/home/transmission-user/downloads", + "incomplete-dir-enabled": false, + "lpd-enabled": false, + "max-peers-global": 200, + "message-level": 1, + "peer-congestion-algorithm": "", + "peer-id-ttl-hours": 6, + "peer-limit-global": 200, + "peer-limit-per-torrent": 50, + "peer-port": 51413, + "peer-port-random-high": 65535, + "peer-port-random-low": 49152, + "peer-port-random-on-start": false, + "peer-socket-tos": "default", + "pex-enabled": true, + "port-forwarding-enabled": false, + "preallocation": 1, + "prefetch-enabled": true, + "queue-stalled-enabled": true, + "queue-stalled-minutes": 30, + "ratio-limit": 2, + "ratio-limit-enabled": false, + "rename-partial-files": true, + "rpc-authentication-required": true, + "rpc-bind-address": "0.0.0.0", + "rpc-enabled": true, + "rpc-host-whitelist": "", + "rpc-host-whitelist-enabled": true, + "rpc-password": "{{ torrents_rpc_password }}", + "rpc-port": 9091, + "rpc-url": "/transmission/", + "rpc-username": "{{ torrents_rpc_username }}", + "rpc-whitelist": "*", + "rpc-whitelist-enabled": true, + "scrape-paused-torrents-enabled": true, + "script-torrent-done-enabled": false, + "script-torrent-done-filename": "", + "seed-queue-enabled": false, + "seed-queue-size": 10, + "speed-limit-down": 100, + "speed-limit-down-enabled": false, + "speed-limit-up": 100, + "speed-limit-up-enabled": false, + "start-added-torrents": true, + "trash-original-torrent-files": false, + "umask": 18, + "upload-limit": 100, + "upload-limit-enabled": 0, + "upload-slots-per-torrent": 14, + "utp-enabled": true +} |
