olimp/roles/qbittorrent/tasks/main.yml
Administrator 6bdeeeed01 Update 2 files
- /roles/qbittorrent/tasks/main.yml
- /group_vars/all.yml
2025-12-08 13:18:27 +05:00

101 lines
3.1 KiB
YAML

---
- name: Create qBittorrent directories
file:
path: "{{ item }}"
state: directory
mode: '0755'
loop:
- "{{ qbittorrent_base_dir }}"
- "{{ qbittorrent_config_dir }}"
- "{{ qbittorrent_downloads_dir }}"
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"
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:
port: "{{ qbittorrent_port_webui }}"
timeout: 60
state: started
tags: qbittorrent
- name: Display access information
debug:
msg: |
✅ qBittorrent успешно развернут!
🔗 Доступ: http://{{ ansible_host }}:{{ qbittorrent_port_webui }}
👤 Имя пользователя: admin
🔑 Пароль: {{ qbittorrent_password }}
📁 Директории:
- Конфигурация: {{ qbittorrent_config_dir }}
- Загрузки: {{ qbittorrent_downloads_dir }}
⚠️ Примечание: Пароль установлен в конфиге и должен работать стабильно.
tags: qbittorrent