From 3e0fdb6074d77f4e08ac3722ae62044caa1012a3 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Sun, 28 Jun 2026 17:02:05 +0200 Subject: [PATCH] Configure transmission --- .../z9/host_vars/opensourcetorrents.sops.yaml | 7 +- .../z9/host_vars/opensourcetorrents.yaml | 92 +++++++++++++++++++ inventories/z9/hosts.yaml | 3 + playbooks/deploy.yaml | 7 ++ .../files/update-transmission-settings | 13 +++ roles/transmission/handlers/main.yaml | 3 + roles/transmission/tasks/main.yaml | 23 +++++ 7 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 roles/transmission/files/update-transmission-settings create mode 100644 roles/transmission/handlers/main.yaml create mode 100644 roles/transmission/tasks/main.yaml diff --git a/inventories/z9/host_vars/opensourcetorrents.sops.yaml b/inventories/z9/host_vars/opensourcetorrents.sops.yaml index 1be8403..e7d56e3 100644 --- a/inventories/z9/host_vars/opensourcetorrents.sops.yaml +++ b/inventories/z9/host_vars/opensourcetorrents.sops.yaml @@ -1,7 +1,8 @@ ansible_pull__age_private_key: ENC[AES256_GCM,data:QB0xpxP8pLfE2ExpCRD4joQzoEcbQZTiVEJbX3t9GyFEseZUtnUCO0ysFUc6hRs2BC9hoPXz6k/dZ0vNkniBmqcN5zTofZ8bg94=,iv:3NVVsae+pgbriTNzgT6rGCEzJjw368WgAKfQCi2qsmQ=,tag:AQSIxJCZOZ8dtlvcu4WMuw==,type:str] +transmission__rpc_password: ENC[AES256_GCM,data:PPEIdI/OcuvX8Mh+zNFSOw==,iv:AgHwT6FGmE9sY3H+MQQc291ILbpNKatEoK8W09wrtr4=,tag:M1E0iS8TTNvu2MABboqCSQ==,type:str] sops: - lastmodified: "2026-06-01T19:05:50Z" - mac: ENC[AES256_GCM,data:ms4yaDEY/2DxC56rxagBRgfkHuy2/AGhZ0om3+gTVfG8/1p7v+qWXuWrNlDjefjhLKVCaf5yl749JZIjs8PP6rTKyTcteqVfoKwx+CFaEA9OmPOaENBV8Kpy2Rrkw8J4UBBKSoTKGFDAGtyysmqbS8eqDuEpb/TbfbbybJUNfe4=,iv:g4IHNmQELptweaqRE7P3LlBTwV+7jt6AfrPowzuziv4=,tag:YkBnOJA5IN1xDhI+umYSow==,type:str] + lastmodified: "2026-06-28T11:50:14Z" + mac: ENC[AES256_GCM,data:c03dDTwriK3lk9HYK5h85ESxC3nvVjBZVIva1ZAbeFu1n8u1IfazBS3NN4NSEZ+TkSW1WdQVKXFiQ9WBawLwLzXSKcmxaOPZuIvxcmbsYGuHAMpO1ODNgvuPP6D6vFl/C+Ew0yRVd72MqlvQKrg46+x6uD+1cvi9w30+EkzV+UY=,iv:UlSDF/0aF0dWYaQc9KAv3pXE1DUflQfFrHIlSt5stJU=,tag:Uj0W//Du0TOugByNFHFf9g==,type:str] pgp: - created_at: "2026-06-01T19:05:22Z" enc: |- @@ -177,4 +178,4 @@ sops: -----END PGP MESSAGE----- fp: 41FFAF3D519CF5C039FBD8414BCC213729AF0E49 unencrypted_suffix: _unencrypted - version: 3.12.2 + version: 3.13.1 diff --git a/inventories/z9/host_vars/opensourcetorrents.yaml b/inventories/z9/host_vars/opensourcetorrents.yaml index 6bcc86d..0df26e6 100644 --- a/inventories/z9/host_vars/opensourcetorrents.yaml +++ b/inventories/z9/host_vars/opensourcetorrents.yaml @@ -1 +1,93 @@ # add /etc/transmission-remote/settings.json here +transmission__settings: + 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 + announce-ip: "" + announce-ip-enabled: false + anti-brute-force-enabled: false + anti-brute-force-threshold: 100 + bind-address-ipv4: "" + bind-address-ipv6: "" + blocklist-enabled: false + blocklist-url: http://www.example.com/blocklist + cache-size-mb: 4 + default-trackers: "" + dht-enabled: true + download-dir: /torrents/complete + 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: /torrents/incomplete + incomplete-dir-enabled: true + lpd-enabled: true + max-peers-global: 200 + message-level: 2 + peer-congestion-algorithm: "" + 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: le + pex-enabled: true + pidfile: "" + port-forwarding-enabled: false + preallocation: 1 + preferred_transport: utp + proxy_url: "" + queue-stalled-enabled: true + queue-stalled-minutes: 30 + ratio-limit: 2 + ratio-limit-enabled: false + rename-partial-files: true + reqq: 2000 + rpc-authentication-required: false + rpc-bind-address: 0.0.0.0 + rpc-enabled: true + rpc-host-whitelist: "" + rpc-host-whitelist-enabled: true + rpc-password: '{{ transmission__rpc_password }}' + rpc-port: 9091 + rpc-socket-mode: "0750" + rpc-url: /transmission/ + rpc-username: "" + rpc-whitelist: 127.0.0.1,::1,172.31.200.*,172.31.201.*,213.240.180.39,2a01:170:118b::1 + rpc-whitelist-enabled: true + scrape-paused-torrents-enabled: true + script-torrent-added-enabled: false + script-torrent-added-filename: "" + script-torrent-done-enabled: false + script-torrent-done-filename: "" + script-torrent-done-seeding-enabled: false + script-torrent-done-seeding-filename: "" + seed-queue-enabled: false + seed-queue-size: 10 + sequential_download: false + sleep-per-seconds-during-verify: 100 + speed-limit-down: 100 + speed-limit-down-enabled: false + speed-limit-up: 100 + speed-limit-up-enabled: false + start-added-torrents: true + start_paused: false + tcp-enabled: true + torrent-added-verify-mode: fast + trash-original-torrent-files: false + umask: "022" + upload-limit: 100 + upload-limit-enabled: 0 + upload-slots-per-torrent: 8 + utp-enabled: true + watch-dir: /torrents/torrents + watch-dir-enabled: true + watch-dir-force-generic: false diff --git a/inventories/z9/hosts.yaml b/inventories/z9/hosts.yaml index 0c6e16d..6044154 100644 --- a/inventories/z9/hosts.yaml +++ b/inventories/z9/hosts.yaml @@ -44,6 +44,9 @@ nginx_hosts: ola_hosts: hosts: light: +transmission: + hosts: + opensourcetorrents: proxmox_vm_template_hosts: hosts: thinkcccore0: diff --git a/playbooks/deploy.yaml b/playbooks/deploy.yaml index b7ce104..d111321 100644 --- a/playbooks/deploy.yaml +++ b/playbooks/deploy.yaml @@ -156,3 +156,10 @@ - knot tags: - knot + +- name: Setup transmission + hosts: transmission + roles: + - transmission + tags: + - transmission diff --git a/roles/transmission/files/update-transmission-settings b/roles/transmission/files/update-transmission-settings new file mode 100644 index 0000000..d51730a --- /dev/null +++ b/roles/transmission/files/update-transmission-settings @@ -0,0 +1,13 @@ +#!/bin/sh + +# +# Update the transmission settings.json. For the update, stop transmission, +# put the new file in place, and restart it. +# + +set -e + +systemctl stop transmission-daemon +cp /etc/transmission-daemon/settings-ansible.json /etc/transmission-daemon/settings.json +chmod 0660 /etc/transmission-daemon/settings.json +systemctl start transmission-daemon diff --git a/roles/transmission/handlers/main.yaml b/roles/transmission/handlers/main.yaml new file mode 100644 index 0000000..781f442 --- /dev/null +++ b/roles/transmission/handlers/main.yaml @@ -0,0 +1,3 @@ +- name: update transmission settings + ansible.builtin.command: /usr/local/sbin/update-transmission-settings + become: true diff --git a/roles/transmission/tasks/main.yaml b/roles/transmission/tasks/main.yaml new file mode 100644 index 0000000..f927ef6 --- /dev/null +++ b/roles/transmission/tasks/main.yaml @@ -0,0 +1,23 @@ +- name: ensure transmission-daemon is installed + ansible.builtin.apt: + name: transmission-daemon + state: present + become: true +- name: ensure update-transmission-settings is deployed + ansible.builtin.copy: + src: "update-transmission-settings" + dest: "/usr/local/sbin/update-transmission-settings" + owner: root + group: root + mode: "0750" + become: true + notify: update transmission settings +- name: ensure transmission settings are deployed + ansible.builtin.copy: + content: '{{ transmission__settings | to_json(indent=4, sort_keys=True) }}' + dest: "/etc/transmission-daemon/settings-ansible.json" + owner: debian-transmission + group: debian-transmission + mode: "0750" + become: true + notify: update transmission settings