diff --git a/group_vars/all.yml b/group_vars/all.yml index f4df3b2..9eed516 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -141,6 +141,16 @@ dashy_config_dir: "{{ dashy_base_dir }}/config" dashy_port: "45132" dashy_domain: "start.zailon.ru" +qbittorrent_base_dir: "/opt/qbittorrent" +qbittorrent_config_dir: "{{ qbittorrent_base_dir }}/config" +qbittorrent_downloads_dir: "{{ qbittorrent_base_dir }}/downloads" +qbittorrent_port_web: "45133" +qbittorrent_port_tcp: "6881" +qbittorrent_port_udp: "6881" +qbittorrent_puid: "1000" +qbittorrent_pgid: "1000" +qbittorrent_image: "lscr.io/linuxserver/qbittorrent:latest" + # ------------ data (192.168.1.202) ------------ bookstack_base_dir: "/mnt/bookstack" bookstack_config_dir: "/mnt/bookstack/config" diff --git a/olimp-deploy.yml b/olimp-deploy.yml index 9cb0b48..bfb6aa5 100644 --- a/olimp-deploy.yml +++ b/olimp-deploy.yml @@ -16,6 +16,7 @@ - { role: docker, tags: deploy_docker } - { role: npm, tags: deploy_npm } - { role: heimdall, tags: deploy_heimdall } + - { role: qbittorrent, tags: deploy_qbittorrent } - hosts: data-server roles: diff --git a/roles/qbittorrent/handlers/main.yml b/roles/qbittorrent/handlers/main.yml new file mode 100644 index 0000000..6e5ec26 --- /dev/null +++ b/roles/qbittorrent/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart qbittorrent + community.docker.docker_compose_v2: + project_src: "{{ qbittorrent_base_dir }}" + state: restarted \ No newline at end of file diff --git a/roles/qbittorrent/tasks/main.yml b/roles/qbittorrent/tasks/main.yml new file mode 100644 index 0000000..9f27243 --- /dev/null +++ b/roles/qbittorrent/tasks/main.yml @@ -0,0 +1,47 @@ +--- +- name: Create qBittorrent directories + file: + path: "{{ item }}" + state: directory + mode: '0755' + loop: + - "{{ qbittorrent_config_dir }}" + - "{{ qbittorrent_downloads_dir }}" + tags: qbittorrent + +- name: Create docker-compose.yml for qBittorrent + template: + src: docker-compose.yml.j2 + dest: "{{ qbittorrent_base_dir }}/docker-compose.yml" + tags: qbittorrent + +- name: Deploy qBittorrent with docker compose + community.docker.docker_compose_v2: + project_src: "{{ qbittorrent_base_dir }}" + state: present + build: no + pull: yes + recreate: always + remove_orphans: yes + tags: qbittorrent + +- name: Wait for qBittorrent to start + wait_for: + port: "{{ qbittorrent_port_web }}" + timeout: 60 + state: started + tags: qbittorrent + +- name: Verify qBittorrent is accessible + uri: + url: "http://localhost:{{ qbittorrent_port_web }}" + status_code: 200 + timeout: 10 + register: qbittorrent_check + tags: qbittorrent + +- name: Show qBittorrent status + debug: + msg: "qBittorrent is running and accessible on port {{ qbittorrent_port_web }}" + when: qbittorrent_check.status == 200 + 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 new file mode 100644 index 0000000..9c61698 --- /dev/null +++ b/roles/qbittorrent/templates/docker-compose.yml.j2 @@ -0,0 +1,26 @@ +--- +services: + qbittorrent: + image: {{ qbittorrent_image }} + container_name: qbittorrent + environment: + - PUID={{ qbittorrent_puid }} + - PGID={{ qbittorrent_pgid }} + - TZ={{ timezone }} + - 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