128 lines
3.8 KiB
YAML

---
- name: Check if YT-DLP worker deployment directory exists
stat:
path: "{{ airflow_worker_dir }}"
register: worker_dir_stat
- name: Ensure YT-DLP worker deployment directory exists
file:
path: "{{ airflow_worker_dir }}"
state: directory
owner: "{{ ssh_user }}"
group: "{{ deploy_group }}"
mode: '0755'
become: yes
when: not worker_dir_stat.stat.exists
- name: Ensure YT-DLP worker configs directory exists
file:
path: "{{ airflow_worker_dir }}/configs"
state: directory
owner: "{{ ssh_user }}"
group: "{{ deploy_group }}"
mode: '0755'
become: yes
- name: "Log: Syncing YT-DLP service files"
debug:
msg: "Syncing YT-DLP service components (config generator, envoy/camoufox templates) to the worker node."
- name: Sync YT-DLP service files to worker
synchronize:
src: "../{{ item }}"
dest: "{{ airflow_worker_dir }}/"
archive: yes
recursive: yes
rsync_path: "sudo rsync"
rsync_opts: "{{ rsync_default_opts }}"
loop:
- "airflow/camoufox"
- name: Sync YT-DLP config generator to worker
synchronize:
src: "../airflow/generate_envoy_config.py"
dest: "{{ airflow_worker_dir }}/"
archive: yes
rsync_path: "sudo rsync"
rsync_opts: "{{ rsync_default_opts }}"
- name: Sync YT-DLP config files to worker
synchronize:
src: "../airflow/configs/{{ item }}"
dest: "{{ airflow_worker_dir }}/configs/"
archive: yes
recursive: yes
rsync_path: "sudo rsync"
rsync_opts: "{{ rsync_default_opts }}"
loop:
- "docker-compose-ytdlp-ops.yaml.j2"
- "docker-compose.config-generate.yaml"
- "envoy.yaml.j2"
- "docker-compose.camoufox.yaml.j2"
- name: Create .env file for YT-DLP worker service
template:
src: "../../templates/.env.j2"
dest: "{{ airflow_worker_dir }}/.env"
mode: "{{ file_permissions }}"
owner: "{{ ssh_user }}"
group: "{{ deploy_group }}"
become: yes
vars:
service_role: "worker"
server_identity: "ytdlp-ops-service-worker-{{ inventory_hostname }}"
- name: "Log: Generating YT-DLP service configurations"
debug:
msg: "Running the configuration generator script inside a temporary Docker container. This creates docker-compose, envoy, and camoufox files based on .env variables."
- name: Generate YT-DLP service configurations
shell:
cmd: "docker compose --project-directory . --env-file .env -f configs/docker-compose.config-generate.yaml run --rm config-generator"
chdir: "{{ airflow_worker_dir }}"
become: yes
become_user: "{{ ssh_user }}"
- name: Pull YT-DLP service image
community.docker.docker_image:
name: "{{ ytdlp_ops_image }}"
source: pull
when: not fast_deploy | default(false)
- name: "Log: Building Camoufox (remote browser) image"
debug:
msg: "Building the Camoufox image locally. This image provides remote-controlled Firefox browsers for token generation."
- name: Build Camoufox image from local Dockerfile
community.docker.docker_image:
name: "camoufox:latest"
build:
path: "{{ airflow_worker_dir }}/camoufox"
source: build
force_source: true
when: not fast_deploy | default(false)
- name: Ensure correct permissions for build context after generation
file:
path: "{{ airflow_worker_dir }}"
state: directory
owner: "{{ ssh_user }}"
group: "{{ deploy_group }}"
recurse: yes
become: yes
- name: "Log: Starting YT-DLP worker services"
debug:
msg: "Starting the core YT-DLP worker services: ytdlp-ops-service (Thrift API), envoy (load balancer), and camoufox (remote browsers)."
- name: Start YT-DLP worker service
community.docker.docker_compose_v2:
project_src: "{{ airflow_worker_dir }}"
files:
- "configs/docker-compose-ytdlp-ops.yaml"
- "configs/docker-compose.camoufox.yaml"
state: present
remove_orphans: true
pull: "{{ 'never' if fast_deploy | default(false) else 'missing' }}"