--- - 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: Информация о подключении block: - name: Создание сообщения set_fact: qb_message: | ============================================ QBITTORRENT ЗАПУЩЕН ============================================ URL: http://{{ ansible_host }}:{{ qbittorrent_port_webui }} Логин: admin {% if qb_temp_password.stdout != "" %} Пароль: {{ qb_temp_password.stdout }} {% else %} Пароль: (сгенерирован, проверьте логи) {% endif %} ============================================ Смените пароль при первом входе! ============================================ - name: Вывод сообщения debug: msg: "{{ qb_message }}"