--- - 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: Настройка пользователя qBittorrent uri: url: "http://localhost:{{ qbittorrent_port_webui }}/api/v2/auth/login" method: POST body_format: form-urlencoded body: username: "admin" password: "adminadmin" status_code: 200 register: login_response until: login_response.status == 200 retries: 10 delay: 5 - name: Смена пароля по умолчанию uri: url: "http://localhost:{{ qbittorrent_port_webui }}/api/v2/app/setPreferences" method: POST body_format: json body: json: '{"web_ui":{"username":"{{ qbittorrent_user }}","password":"{{ qbittorrent_password }}","session_timeout":3600}}' headers: Cookie: "{{ login_response.set_cookie }}" status_code: 200 when: login_response.status == 200