- /roles/qbittorrent/tasks/main.yml - /roles/qbittorrent/templates/docker-compose.yml.j2 - /group_vars/all.yml
166 lines
5.2 KiB
YAML
166 lines
5.2 KiB
YAML
---
|
|
- name: Create qBittorrent base and local directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: "{{ qbittorrent_puid }}"
|
|
group: "{{ qbittorrent_pgid }}"
|
|
loop:
|
|
- "{{ qbittorrent_base_dir }}"
|
|
- "{{ qbittorrent_config_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
|
|
|
|
- name: Generate password hash for qBittorrent
|
|
shell: |
|
|
echo -n "admin:Web UI:{{ qbittorrent_password }}" | md5sum | awk '{print $1}'
|
|
register: password_hash
|
|
changed_when: false
|
|
no_log: true
|
|
tags: qbittorrent
|
|
|
|
- name: Create qBittorrent configuration with password hash
|
|
copy:
|
|
content: |
|
|
# Auto-generated qBittorrent configuration
|
|
[AutoRun]
|
|
enabled=false
|
|
[BitTorrent]
|
|
Session\DefaultSavePath=/downloads
|
|
Session\Port={{ qbittorrent_port_torrent }}
|
|
[Core]
|
|
AutoDeleteAddedTorrentFile=Never
|
|
[LegalNotice]
|
|
Accepted=true
|
|
[Preferences]
|
|
Connection\PortRangeMin={{ qbittorrent_port_torrent }}
|
|
Connection\PortRangeMax={{ qbittorrent_port_torrent }}
|
|
Downloads\SavePath=/downloads
|
|
Downloads\TempPath=/downloads/incomplete
|
|
WebUI\Address=*
|
|
WebUI\Port=8080
|
|
WebUI\LocalHostAuth=false
|
|
WebUI\AuthSubnetWhitelist=192.168.1.0/24
|
|
WebUI\UseUPnP=false
|
|
WebUI\ClickjackingProtection=false
|
|
WebUI\CSRFProtection=false
|
|
WebUI\HostHeaderValidation=false
|
|
WebUI\DomainList=192.168.1.201:{{ qbittorrent_port_webui }},localhost:{{ qbittorrent_port_webui }}
|
|
WebUI\MaxAuthenticationFailCount=-1
|
|
WebUI\Username=admin
|
|
WebUI\Password_PBKDF2="@ByteArray({{ password_hash.stdout }}:100000)"
|
|
WebUI\Password_ha1=@ByteArray({{ password_hash.stdout }})
|
|
Advanced\RecheckOnCompletion=false
|
|
dest: "{{ qbittorrent_config_dir }}/qBittorrent.conf"
|
|
owner: "{{ qbittorrent_puid }}"
|
|
group: "{{ qbittorrent_pgid }}"
|
|
mode: '0644'
|
|
tags: qbittorrent
|
|
|
|
- name: Deploy docker-compose.yml
|
|
template:
|
|
src: docker-compose.yml.j2
|
|
dest: "{{ qbittorrent_base_dir }}/docker-compose.yml"
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
tags: qbittorrent
|
|
|
|
- name: Start qBittorrent container with docker compose
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ qbittorrent_base_dir }}"
|
|
state: present
|
|
pull: "always"
|
|
build: "never"
|
|
recreate: "always"
|
|
remove_orphans: yes
|
|
tags: qbittorrent
|
|
|
|
- name: Wait for qBittorrent to start
|
|
wait_for:
|
|
host: "127.0.0.1"
|
|
port: "{{ qbittorrent_port_webui }}"
|
|
timeout: 120
|
|
delay: 5
|
|
tags: qbittorrent
|
|
|
|
- name: Display access and mount info
|
|
debug:
|
|
msg: |
|
|
✅ qBittorrent успешно развернут на {{ ansible_host }}!
|
|
🔗 Доступ: http://{{ ansible_host }}:{{ qbittorrent_port_webui }}
|
|
👤 Логин: admin | 🔑 Пароль: {{ qbittorrent_password }}
|
|
📁 Локальные точки монтирования:
|
|
{% for share in qbittorrent_shares %}
|
|
- {{ share.name }} → {{ share.dest }}
|
|
{% endfor %}
|
|
💡 Совет: в веб-интерфейсе создайте категории («Фильмы», «Сериалы», «Аниме») и укажите пути:
|
|
- Фильмы → /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 |