Update 3 files

- /roles/qbittorrent/tasks/main.yml
- /roles/qbittorrent/templates/docker-compose.yml.j2
- /group_vars/all.yml
This commit is contained in:
Administrator 2025-12-17 19:38:37 +05:00
parent a3290701d6
commit 1d7dbe9d76
3 changed files with 144 additions and 21 deletions

View File

@ -212,6 +212,61 @@ qbittorrent_port_webui: 45135
qbittorrent_port_torrent: 6881 qbittorrent_port_torrent: 6881
qbittorrent_password: "13qeadZC" qbittorrent_password: "13qeadZC"
qbittorrent_shares:
# Windows-шара с входящими торрентами
- name: downloads
src: "//192.168.1.101/Downloads"
dest: "/mnt/downloads"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: abook
src: "//192.168.1.203/Abook"
dest: "/mnt/video/abook"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: music
src: "//192.168.1.203/Music"
dest: "/mnt/audio"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: books
src: "//192.168.1.203/Books"
dest: "/mnt/books"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: films
src: "//192.168.1.203/Films"
dest: "/mnt/video/films"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: mult
src: "//192.168.1.203/Mult"
dest: "/mnt/video/mult"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: anime
src: "//192.168.1.203/Anime"
dest: "/mnt/video/anime"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: serial
src: "//192.168.1.203/Serial"
dest: "/mnt/video/serial"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: mserials
src: "//192.168.1.203/Mserials"
dest: "/mnt/video/mserials"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: doc
src: "//192.168.1.203/Doc"
dest: "/mnt/documents"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: ztube
src: "//192.168.1.203/Ztube"
dest: "/mnt/video/ztube"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: show
src: "//192.168.1.203/Show"
dest: "/mnt/video/show"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
- name: games
src: "//192.168.1.207/Games"
dest: "/mnt/games"
opts: "uid={{ qbittorrent_puid }},gid={{ qbittorrent_pgid }},file_mode=0777,dir_mode=0777,iocharset=utf8"
torrserver_base_dir: "/mnt/service/torrserver" torrserver_base_dir: "/mnt/service/torrserver"
torrserver_config_dir: "{{ torrserver_base_dir }}/config" torrserver_config_dir: "{{ torrserver_base_dir }}/config"
torrserver_torrents_dir: "{{ torrserver_base_dir }}/torrents" torrserver_torrents_dir: "{{ torrserver_base_dir }}/torrents"

View File

@ -1,13 +1,70 @@
--- ---
- name: Create qBittorrent directories - name: Create qBittorrent base and local directories
file: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: '0755' mode: '0755'
owner: "{{ qbittorrent_puid }}"
group: "{{ qbittorrent_pgid }}"
loop: loop:
- "{{ qbittorrent_base_dir }}" - "{{ qbittorrent_base_dir }}"
- "{{ qbittorrent_config_dir }}" - "{{ qbittorrent_config_dir }}"
- "{{ qbittorrent_downloads_dir }}" - "{{ qbittorrent_downloads_dir }}"
- "/mnt/downloads"
- "/mnt/video"
- "/mnt/video/abook"
- "/mnt/video/films"
- "/mnt/video/mult"
- "/mnt/video/anime"
- "/mnt/video/serial"
- "/mnt/video/mserials"
- "/mnt/video/ztube"
- "/mnt/video/show"
- "/mnt/audio"
- "/mnt/books"
- "/mnt/documents"
- "/mnt/games"
tags: qbittorrent
- name: Ensure cifs-utils is installed
apt:
name: cifs-utils
state: present
tags: qbittorrent
- name: Create SMB credentials file
copy:
content: |
username=Zailon
password=Welc0metohell
dest: /etc/smb-creds-qbt
owner: root
group: root
mode: '0600'
tags: qbittorrent
- name: Mount all SMB shares
mount:
src: "{{ item.src }}"
path: "{{ item.dest }}"
fstype: cifs
opts: "{{ item.opts }},credentials=/etc/smb-creds-qbt"
state: mounted
loop: "{{ qbittorrent_shares }}"
tags: qbittorrent
- name: Verify write access for UID {{ qbittorrent_puid }}
command: runuser -u {{ qbittorrent_puid }} -- touch "{{ item.dest }}/.qbt_mount_test"
loop: "{{ qbittorrent_shares }}"
register: write_test
ignore_errors: yes
tags: qbittorrent
- name: Fail if any share is not writable
fail:
msg: "❌ Нет прав на запись в шару {{ item.item.dest }} (проверьте SMB-сервер, права, UID/GID)"
when: item.failed
loop: "{{ write_test.results }}"
tags: qbittorrent tags: qbittorrent
- name: Generate password hash for qBittorrent - name: Generate password hash for qBittorrent
@ -24,17 +81,13 @@
# Auto-generated qBittorrent configuration # Auto-generated qBittorrent configuration
[AutoRun] [AutoRun]
enabled=false enabled=false
[BitTorrent] [BitTorrent]
Session\DefaultSavePath=/downloads Session\DefaultSavePath=/downloads
Session\Port={{ qbittorrent_port_torrent }} Session\Port={{ qbittorrent_port_torrent }}
[Core] [Core]
AutoDeleteAddedTorrentFile=Never AutoDeleteAddedTorrentFile=Never
[LegalNotice] [LegalNotice]
Accepted=true Accepted=true
[Preferences] [Preferences]
Connection\PortRangeMin={{ qbittorrent_port_torrent }} Connection\PortRangeMin={{ qbittorrent_port_torrent }}
Connection\PortRangeMax={{ qbittorrent_port_torrent }} Connection\PortRangeMax={{ qbittorrent_port_torrent }}
@ -55,6 +108,8 @@
WebUI\Password_ha1=@ByteArray({{ password_hash.stdout }}) WebUI\Password_ha1=@ByteArray({{ password_hash.stdout }})
Advanced\RecheckOnCompletion=false Advanced\RecheckOnCompletion=false
dest: "{{ qbittorrent_config_dir }}/qBittorrent.conf" dest: "{{ qbittorrent_config_dir }}/qBittorrent.conf"
owner: "{{ qbittorrent_puid }}"
group: "{{ qbittorrent_pgid }}"
mode: '0644' mode: '0644'
tags: qbittorrent tags: qbittorrent
@ -79,23 +134,33 @@
- name: Wait for qBittorrent to start - name: Wait for qBittorrent to start
wait_for: wait_for:
host: "127.0.0.1"
port: "{{ qbittorrent_port_webui }}" port: "{{ qbittorrent_port_webui }}"
timeout: 60 timeout: 120
state: started delay: 5
tags: qbittorrent tags: qbittorrent
- name: Display access information - name: Display access and mount info
debug: debug:
msg: | msg: |
✅ qBittorrent успешно развернут! ✅ qBittorrent успешно развернут на {{ ansible_host }}!
🔗 Доступ: http://{{ ansible_host }}:{{ qbittorrent_port_webui }} 🔗 Доступ: http://{{ ansible_host }}:{{ qbittorrent_port_webui }}
👤 Имя пользователя: admin 👤 Логин: admin | 🔑 Пароль: {{ qbittorrent_password }}
🔑 Пароль: {{ qbittorrent_password }} 📁 Локальные точки монтирования:
{% for share in qbittorrent_shares %}
📁 Директории: - {{ share.name }} → {{ share.dest }}
- Конфигурация: {{ qbittorrent_config_dir }} {% endfor %}
- Загрузки: {{ qbittorrent_downloads_dir }} 💡 Совет: в веб-интерфейсе создайте категории («Фильмы», «Сериалы», «Аниме») и укажите пути:
- Фильмы → /mnt/video/films
⚠️ Примечание: Пароль установлен в конфиге и должен работать стабильно. - Сериалы → /mnt/video/serial
- Аниме → /mnt/video/anime
- Мультфильмы → /mnt/video/mult
- Мультсериалы → /mnt/video/mserials
- Аудиокниги → /mnt/video/abook
- Музыка → /mnt/audio
- Книги → /mnt/books
- Документалистика → /mnt/documents
- Игры → /mnt/games
- YouTube → /mnt/video/ztube
- Шоу → /mnt/video/show
tags: qbittorrent tags: qbittorrent

View File

@ -11,8 +11,11 @@ services:
volumes: volumes:
- {{ qbittorrent_config_dir }}:/config - {{ qbittorrent_config_dir }}:/config
- {{ qbittorrent_downloads_dir }}:/downloads - {{ qbittorrent_downloads_dir }}:/downloads
{% for share in qbittorrent_shares %}
- {{ share.dest }}:{{ share.dest }}:rw
{% endfor %}
ports: ports:
- {{ qbittorrent_port_webui }}:8080 - "{{ qbittorrent_port_webui }}:8080"
- 6881:6881 - "6881:6881"
- 6881:6881/udp - "6881:6881/udp"
restart: unless-stopped restart: unless-stopped