Add Atlas qBittorrent service configuration

This commit is contained in:
Fabio Scotto di Santolo
2026-10-10 13:49:55 +02:00
parent 7d80c57570
commit c8df4dde87
8 changed files with 259 additions and 0 deletions

View File

@@ -204,6 +204,13 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
when it is assigned. After a firewalld reload, restore Prometheus' rootful Podman networking with when it is assigned. After a firewalld reload, restore Prometheus' rootful Podman networking with
`podman network reload --all` so the existing proxy stack retains container DNS. `podman network reload --all` so the existing proxy stack retains container DNS.
- Atlas qBittorrent is selected by `atlas_manage_qbittorrent` and managed with the
`qbittorrent` tag as the admin-owned rootless `atlas-qbittorrent.service` Quadlet.
Its LAN-only Web UI is `http://192.168.178.55:8090`; configuration lives in
`services/data/qbittorrent`, and only `Archive/Downloads` is writable as payload
storage. It uses the home Internet connection, not WireGuard or a VPN; no router
forwarding or published torrent peer port is configured. See `docs/atlas-qbittorrent.md`.
## Atlas NAS TODO ## Atlas NAS TODO
Completed validation: the existing RAIDZ2 pool and datasets, SELinux, LAN firewall, SSH, Cockpit with Completed validation: the existing RAIDZ2 pool and datasets, SELinux, LAN firewall, SSH, Cockpit with
the selected 45Drives plugins, encrypted SMB3 `Archive`, the Aegis-only NFSv4 `photobook` export, and the the selected 45Drives plugins, encrypted SMB3 `Archive`, the Aegis-only NFSv4 `photobook` export, and the

View File

@@ -257,3 +257,7 @@ host_enabled_services:
- cockpit.socket - cockpit.socket
- pmlogger.service - pmlogger.service
- zfs.target - zfs.target
# LAN-only torrent Web UI; downloads use the home Internet connection.
atlas_manage_qbittorrent: true
atlas_qbittorrent_image: docker.io/qbittorrentofficial/qbittorrent-nox@sha256:92bfd78d731e254ba64f62b77b0696add6447a33642ee5feda106a26b285aa7f

View File

@@ -297,3 +297,9 @@ atlas_media_quadlet_services:
- atlas-immich-machine-learning.service - atlas-immich-machine-learning.service
- atlas-immich-server.service - atlas-immich-server.service
- atlas-npm.service - atlas-npm.service
atlas_manage_qbittorrent: false
atlas_qbittorrent_image: CHANGEME_PINNED_QBITTORRENT_IMAGE
atlas_qbittorrent_state_dir: "{{ atlas_app_data_mountpoint }}/qbittorrent"
atlas_qbittorrent_downloads_dir: "{{ atlas_archive_mountpoint }}/Downloads"
atlas_qbittorrent_web_port: 8090

View File

@@ -26,6 +26,9 @@
- name: Import Atlas iCloudPD storage and boot-started Quadlet tasks - name: Import Atlas iCloudPD storage and boot-started Quadlet tasks
ansible.builtin.import_tasks: icloudpd.yml ansible.builtin.import_tasks: icloudpd.yml
- name: Import Atlas torrent service
ansible.builtin.import_tasks: qbittorrent.yml
- name: Import Atlas ZFS maintenance tasks - name: Import Atlas ZFS maintenance tasks
ansible.builtin.import_tasks: zfs_maintenance.yml ansible.builtin.import_tasks: zfs_maintenance.yml

View File

@@ -0,0 +1,124 @@
---
- name: Manage Atlas rootless qBittorrent
tags: [atlas, qbittorrent]
when: atlas_manage_qbittorrent | bool
block:
- name: Require isolated paths and a pinned image
ansible.builtin.assert:
that:
- atlas_manage_storage | bool
- atlas_qbittorrent_state_dir == atlas_app_data_mountpoint ~ '/qbittorrent'
- atlas_qbittorrent_downloads_dir == atlas_archive_mountpoint ~ '/Downloads'
- atlas_qbittorrent_image is search('@sha256:[0-9a-f]{64}$')
- name: Inspect the existing parent datasets
community.general.zfs_facts:
name: "{{ item.dataset }}"
properties: name,mounted,mountpoint
loop:
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_archive }}"
mountpoint: "{{ atlas_archive_mountpoint }}"
- dataset: "{{ atlas_zfs_pool }}/{{ atlas_zfs_dataset_app_data }}"
mountpoint: "{{ atlas_app_data_mountpoint }}"
register: atlas_qbittorrent_parents
- name: Refuse missing or unmounted parent datasets
ansible.builtin.assert:
that:
- item.ansible_facts.ansible_zfs_datasets | length == 1
- item.ansible_facts.ansible_zfs_datasets[0].mounted == 'yes'
- item.ansible_facts.ansible_zfs_datasets[0].mountpoint == item.item.mountpoint
loop: "{{ atlas_qbittorrent_parents.results }}"
loop_control:
label: "{{ item.item.dataset }}"
- name: Inspect the proposed download directory without following links
ansible.builtin.stat:
path: "{{ atlas_qbittorrent_downloads_dir }}"
follow: false
register: atlas_qbittorrent_downloads
- name: Refuse unrelated or symlinked download paths
ansible.builtin.assert:
that:
- >-
not atlas_qbittorrent_downloads.stat.exists or
(atlas_qbittorrent_downloads.stat.isdir | default(false) and
atlas_qbittorrent_downloads.stat.uid | int == atlas_admin_uid | int)
- name: Create the dedicated configuration dataset
community.general.zfs:
name: "{{ atlas_zfs_pool }}/services/data/qbittorrent"
state: present
extra_zfs_properties:
compression: zstd
mountpoint: "{{ atlas_qbittorrent_state_dir }}"
- name: Prepare private state and the SMB download directory
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: "{{ atlas_admin_username }}"
group: "{{ atlas_admin_group }}"
mode: "{{ item.mode }}"
loop:
- {path: "{{ atlas_qbittorrent_state_dir }}", mode: "0700"}
- {path: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config", mode: "0700"}
- {path: "{{ atlas_qbittorrent_downloads_dir }}", mode: "0770"}
- {path: "{{ atlas_admin_home }}/.config/containers/systemd", mode: "0700"}
- name: Seed qBittorrent settings without overwriting application-managed state
ansible.builtin.template:
src: atlas-qbittorrent.conf.j2
dest: "{{ atlas_qbittorrent_state_dir }}/qBittorrent/config/qBittorrent.conf"
owner: "{{ atlas_admin_username }}"
group: "{{ atlas_admin_group }}"
mode: "0600"
force: false
diff: false
- name: Allow only the declared LAN to reach the Web UI
ansible.posix.firewalld:
zone: "{{ atlas_firewalld_zone }}"
rich_rule: >-
rule family="ipv4" source address="{{ atlas_lan_subnet }}"
port port="{{ atlas_qbittorrent_web_port }}" protocol="tcp" accept
permanent: true
immediate: true
state: enabled
- name: Keep the rootless user manager available at boot
ansible.builtin.command: "loginctl enable-linger {{ atlas_admin_username }}"
args:
creates: "/var/lib/systemd/linger/{{ atlas_admin_username }}"
- name: Render the rootless torrent Quadlet
ansible.builtin.template:
src: atlas-qbittorrent.container.j2
dest: "{{ atlas_admin_home }}/.config/containers/systemd/atlas-qbittorrent.container"
owner: "{{ atlas_admin_username }}"
group: "{{ atlas_admin_group }}"
mode: "0644"
register: atlas_qbittorrent_quadlet
- name: Start qBittorrent and restart only after a Quadlet change
become_user: "{{ atlas_admin_username }}"
ansible.builtin.systemd:
name: atlas-qbittorrent.service
scope: user
daemon_reload: "{{ atlas_qbittorrent_quadlet.changed }}"
state: "{{ 'restarted' if atlas_qbittorrent_quadlet.changed else 'started' }}"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ atlas_admin_uid }}"
DBUS_SESSION_BUS_ADDRESS: "unix:path=/run/user/{{ atlas_admin_uid }}/bus"
when: not ansible_check_mode
- name: Verify the Web UI responds on the LAN address
ansible.builtin.uri:
url: "http://{{ ansible_host }}:{{ atlas_qbittorrent_web_port }}/"
status_code: 200
register: atlas_qbittorrent_http
retries: 15
delay: 2
until: atlas_qbittorrent_http is succeeded
when: not ansible_check_mode

View File

@@ -0,0 +1,17 @@
; Seeded once by Ansible. Subsequent settings are managed through the Web UI.
[BitTorrent]
Session\DefaultSavePath=/downloads
Session\TempPath=/downloads/.incomplete
Session\TempPathEnabled=true
Session\Port=6881
[Meta]
MigrationVersion=9999
[Network]
PortForwardingEnabled=false
[Preferences]
WebUI\Port={{ atlas_qbittorrent_web_port }}
WebUI\LocalHostAuth=true
WebUI\AuthSubnetWhitelistEnabled=false
WebUI\CSRFProtection=true
WebUI\ClickjackingProtection=true
WebUI\HostHeaderValidation=true

View File

@@ -0,0 +1,33 @@
# Managed by Ansible. No VPN, host networking or router port forwarding.
[Unit]
Description=Atlas rootless qBittorrent
RequiresMountsFor={{ atlas_qbittorrent_state_dir }} {{ atlas_qbittorrent_downloads_dir }}
[Container]
ContainerName=atlas-qbittorrent
Image={{ atlas_qbittorrent_image }}
UserNS=keep-id
User={{ atlas_admin_uid }}
Group={{ atlas_admin_gid }}
PublishPort={{ ansible_host }}:{{ atlas_qbittorrent_web_port }}:{{ atlas_qbittorrent_web_port }}
Environment=QBT_LEGAL_NOTICE=confirm
Environment=QBT_WEBUI_PORT={{ atlas_qbittorrent_web_port }}
Environment=XDG_CACHE_HOME=/tmp/cache
Environment=TZ={{ atlas_timezone }}
Environment=UMASK=007
Volume={{ atlas_qbittorrent_state_dir }}:/config:Z
Volume={{ atlas_qbittorrent_downloads_dir }}:/downloads:z
ReadOnly=true
Tmpfs=/tmp:rw,nosuid,nodev
NoNewPrivileges=true
DropCapability=all
StopTimeout=1800
[Service]
Restart=on-failure
RestartSec=10
TimeoutStartSec=900
TimeoutStopSec=1900
[Install]
WantedBy=default.target

65
docs/atlas-qbittorrent.md Normal file
View File

@@ -0,0 +1,65 @@
# Atlas qBittorrent
Atlas runs the official qBittorrent-nox image, pinned by digest, in the
admin-owned rootless `atlas-qbittorrent.service` Quadlet. No VPN is involved:
outbound traffic uses Atlas' normal home-network default route. Existing
WireGuard configuration is unchanged.
- LAN Web UI: `http://192.168.178.55:8090` (LAN-only firewalld rule).
- Downloads: `/zpool/archive/Downloads`, available through SMB `Archive`.
- Private configuration dataset: `zpool/services/data/qbittorrent`.
- Only configuration and Downloads are mounted in the container.
- UPnP/NAT-PMP is disabled in the initial settings. No torrent peer port is
published and no router port forwarding is configured. Outbound connections
work; inbound peer connectivity and seeding are consequently limited.
- The Web UI keeps authentication and CSRF/Host-header protection enabled.
Initial settings are seeded only once, preserving passwords and settings
subsequently changed in the application.
## Deployment
From the repository root:
```sh
ansible-playbook ansible/site.yml --limit atlas --tags qbittorrent --check --diff
ansible-playbook ansible/site.yml --limit atlas --tags qbittorrent
```
The service starts at boot through `WantedBy=default.target` and admin lingering.
A real reboot must be verified separately. Only a changed Quadlet restarts the
service on subsequent playbook runs.
## First login
Username: `admin`. The application generates a temporary password at startup.
Read it privately on Atlas, without pasting it into chat:
```sh
ssh admin@192.168.178.55 'podman logs atlas-qbittorrent 2>&1 | grep "temporary password" | tail -1'
```
Set a permanent password immediately under Web UI settings. Temporary passwords
change after restarting until a permanent password is saved. LAN access uses
HTTP; do not expose this port to the Internet. An SSH tunnel may be used instead
for encrypted access.
Downloads are inside Archive and inherit its existing snapshot, Borg and offline
USB backup scope. Large downloads and incomplete files therefore affect backup
capacity. No backup exclusions or automatic deletion are introduced.
Official image documentation:
<https://github.com/qbittorrent/docker-qbittorrent-nox>
## Verified on 2026-10-10
The pinned image reports qBittorrent v5.2.4. Targeted deployment succeeded and a
second application reported `changed=0`, `failed=0`. LAN HTTP returned 200 from
Ikaros; unauthenticated API access returned 403. Authenticated API checks verified
the download paths, required authentication, Host-header/CSRF protection, and
port forwarding disabled, including after a qBittorrent service restart. Existing
Gitea, Navidrome, Syncthing and iCloudPD services remained active.
A real torrent download and a host reboot have not been tested. The initial
WebUI port mapping was corrected to use 8090 internally and externally, preserving
Host-header validation. qBittorrent 5.2 uses `[Network] PortForwardingEnabled=false`
for its persistent UPnP/NAT-PMP option.