diff --git a/group_vars/all.yml b/group_vars/all.yml index 6467b93..3ffff0e 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -142,13 +142,12 @@ dashy_port: "45132" dashy_domain: "start.zailon.ru" --- -qbittorrent_base_dir: "/mnt/qbittorrent" -qbittorrent_config_dir: "{{ qbittorrent_base_dir }}/config" +qbittorrent_base_dir: "/opt/qbittorrent" +qbittorrent_config_dir: "{{ qbittorrent_base_dir }}/appdata" qbittorrent_downloads_dir: "{{ qbittorrent_base_dir }}/downloads" +qbittorrent_puid: 1000 +qbittorrent_pgid: 1000 qbittorrent_port_webui: 45133 -qbittorrent_port_torrent: 6881 -qbittorrent_webui_username: "zailon" -qbittorrent_webui_password: "13qeadZC" # ------------ data (192.168.1.202) ------------ bookstack_base_dir: "/mnt/bookstack" diff --git a/roles/qbittorrent/tasks/main.yml b/roles/qbittorrent/tasks/main.yml index 4980bb1..7f7cd7f 100644 --- a/roles/qbittorrent/tasks/main.yml +++ b/roles/qbittorrent/tasks/main.yml @@ -5,97 +5,55 @@ state: directory mode: '0755' loop: + - "{{ qbittorrent_base_dir }}" - "{{ qbittorrent_config_dir }}" - "{{ qbittorrent_downloads_dir }}" tags: qbittorrent -- name: Create docker-compose.yml for 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: Deploy qBittorrent with docker compose +- name: Start qBittorrent container with docker compose community.docker.docker_compose_v2: project_src: "{{ qbittorrent_base_dir }}" state: present - build: never - pull: always - recreate: always - remove_orphans: yes + pull: "always" + build: "never" tags: qbittorrent - name: Wait for qBittorrent to start wait_for: - port: "{{ qbittorrent_port_web }}" + port: "{{ qbittorrent_port_webui }}" timeout: 60 state: started tags: qbittorrent -- name: Check qBittorrent health with retry - uri: - url: "http://localhost:{{ qbittorrent_port_web }}" - status_code: [200, 401, 403] - timeout: 5 - register: qbittorrent_health - until: qbittorrent_health.status == 200 or qbittorrent_health.status == 401 - retries: 12 - delay: 5 +- name: Get temporary password from logs + shell: | + docker logs qbittorrent 2>&1 | grep "temporary password" | tail -1 | awk '{print $NF}' + register: temp_password + changed_when: false tags: qbittorrent -- name: Display qBittorrent deployment success +- name: Display access information debug: msg: | ✅ qBittorrent успешно развернут! - 📊 Статус сервиса: - - Веб-интерфейс: http://{{ ansible_host }}:{{ qbittorrent_port_web }} - - HTTP статус: {{ qbittorrent_health.status }} - - Контейнер: qbittorrent + 🔗 Доступ: http://{{ ansible_host }}:{{ qbittorrent_port_webui }} + 👤 Имя пользователя: admin + 🔑 Временный пароль: {{ temp_password.stdout }} - 🔐 Учетные данные по умолчанию: - - Логин: admin - - Пароль: adminadmin - - ⚠️ ВНИМАНИЕ: Смените пароль после первого входа! + ⚠️ ВАЖНО: Войдите немедленно и смените пароль в веб-интерфейсе! + Этот временный пароль изменится при перезапуске контейнера. 📁 Директории: - Конфигурация: {{ qbittorrent_config_dir }} - Загрузки: {{ qbittorrent_downloads_dir }} - - 🔧 Команды управления: - - Остановить: docker stop qbittorrent - - Запустить: docker start qbittorrent - - Перезапустить: docker restart qbittorrent - tags: qbittorrent - -- name: Create access info file - copy: - content: | - # qBittorrent Access Information - # Generated by Ansible on {{ ansible_date_time.date }} - - Web Interface: http://{{ ansible_host }}:{{ qbittorrent_port_web }} - Default Username: admin - Default Password: adminadmin - - IMPORTANT: Change the default password after first login! - - Directories: - Config: {{ qbittorrent_config_dir }} - Downloads: {{ qbittorrent_downloads_dir }} - - Docker Commands: - Status: docker ps | grep qbittorrent - Logs: docker logs qbittorrent - Restart: docker restart qbittorrent - - First Steps: - 1. Open http://{{ ansible_host }}:{{ qbittorrent_port_web }} - 2. Login with admin/adminadmin - 3. Go to Tools → Options → Web UI - 4. Change the password - 5. Configure download directory: {{ qbittorrent_downloads_dir }} - dest: "{{ qbittorrent_base_dir }}/ACCESS_INFO.txt" - mode: '0644' tags: qbittorrent \ No newline at end of file diff --git a/roles/qbittorrent/templates/docker-compose.yml.j2 b/roles/qbittorrent/templates/docker-compose.yml.j2 index 33045a0..c3ffc19 100644 --- a/roles/qbittorrent/templates/docker-compose.yml.j2 +++ b/roles/qbittorrent/templates/docker-compose.yml.j2 @@ -4,25 +4,16 @@ services: image: lscr.io/linuxserver/qbittorrent:latest container_name: qbittorrent environment: - - PUID=1000 - - PGID=1000 + - PUID={{ qbittorrent_puid }} + - PGID={{ qbittorrent_pgid }} - TZ={{ timezone }} - - WEBUI_PORT={{ qbittorrent_port_webui }} - - WEBUI_USERNAME={{ qbittorrent_webui_username }} - - WEBUI_PASSWORD={{ qbittorrent_webui_password }} + - WEBUI_PORT=8080 - TORRENTING_PORT=6881 volumes: - {{ qbittorrent_config_dir }}:/config - {{ qbittorrent_downloads_dir }}:/downloads ports: - - {{ qbittorrent_port_web }}:8080 - - {{ qbittorrent_port_tcp }}:6881 - - {{ qbittorrent_port_udp }}:6881/udp - restart: unless-stopped - networks: - - default - -networks: - default: - name: qbittorrent_network - driver: bridge \ No newline at end of file + - {{ qbittorrent_port_webui }}:8080 + - 6881:6881 + - 6881:6881/udp + restart: unless-stopped \ No newline at end of file