olimp/roles/qbittorrent/tasks/main.yml
2025-12-18 13:13:26 +05:00

78 lines
3.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- name: Создание директорий для qBittorrent
file:
path: "{{ item }}"
state: directory
owner: "{{ qbittorrent_puid }}"
group: "{{ qbittorrent_pgid }}"
mode: '0755'
loop:
- "{{ qbittorrent_config_dir }}"
- "{{ qbittorrent_downloads_dir }}"
- name: Создание директории для учетных данных SMB
file:
path: "{{ qbittorrent_smb_credentials_dir }}"
state: directory
mode: '0700'
- name: Создание файлов учетных данных SMB
template:
src: smb-credentials.j2
dest: "{{ qbittorrent_smb_credentials_dir }}/{{ item.key }}"
mode: '0600'
loop: "{{ qbittorrent_smb_creds | dict2items }}"
loop_control:
label: "{{ item.key }}"
- name: Монтирование SMB-шаров
mount:
path: "{{ item.dest }}"
src: "{{ item.src }}"
fstype: cifs
opts: "{{ item.opts }}{% if item.credential is defined %},credentials={{ qbittorrent_smb_credentials_dir }}/{{ item.credential }}{% endif %}"
state: mounted
loop: "{{ qbittorrent_shares }}"
loop_control:
label: "{{ item.name }}"
- name: Копирование docker-compose файла для qBittorrent
template:
src: docker-compose.yml.j2
dest: "{{ qbittorrent_base_dir }}/docker-compose.yml"
mode: '0644'
- name: Запуск qBittorrent контейнера
community.docker.docker_compose_v2:
project_src: "{{ qbittorrent_base_dir }}"
state: present
- name: Ожидание запуска qBittorrent
wait_for:
port: "{{ qbittorrent_port_webui }}"
timeout: 60
- name: Ждем генерации пароля в логах
pause:
seconds: 5
- name: Получение временного пароля из логов
shell: |
docker logs qbittorrent 2>/dev/null | grep -o "temporary password is: [A-Za-z0-9]*" | tail -1 | awk '{print $NF}'
register: qb_temp_password
failed_when: false
changed_when: false
- name: Информация о подключении
debug:
msg: |
╔══════════════════════════════════════════════════════════╗
║ qBittorrent Запущен! ║
╠══════════════════════════════════════════════════════════╣
Веб-интерфейс: http://{{ ansible_host }}:{{ qbittorrent_port_webui }} ║
║ Логин по умолчанию: admin ║
{% if qb_temp_password.stdout != "" %}
║ Временный пароль: {{ qb_temp_password.stdout }} ║
{% else %}
║ ║
║ ⚠️ Смените пароль при первом входе! ║
╚══════════════════════════════════════════════════════════╝