101 lines
3.0 KiB
YAML
101 lines
3.0 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: ytdl
|
|
mode: '0755'
|
|
become: yes
|
|
when: not worker_dir_stat.stat.exists
|
|
|
|
- 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/docker-compose-ytdlp-ops.yaml.j2"
|
|
- "airflow/docker-compose.config-generate.yaml"
|
|
- "airflow/generate_envoy_config.py"
|
|
- "airflow/init-yt-service.sh"
|
|
- "airflow/envoy.yaml.j2"
|
|
- "airflow/camoufox"
|
|
|
|
- name: Create .env file for YT-DLP worker service
|
|
template:
|
|
src: "../../templates/.env.worker.j2"
|
|
dest: "{{ airflow_worker_dir }}/.env"
|
|
mode: "{{ file_permissions }}"
|
|
owner: "{{ ssh_user }}"
|
|
group: ytdl
|
|
become: yes
|
|
vars:
|
|
service_role: "worker"
|
|
server_identity: "ytdlp-ops-service-worker-{{ inventory_hostname }}"
|
|
|
|
- name: Make YT-DLP service init script executable
|
|
file:
|
|
path: "{{ airflow_worker_dir }}/init-yt-service.sh"
|
|
mode: "0755"
|
|
become: yes
|
|
|
|
- name: Run YT-DLP service init script
|
|
shell:
|
|
cmd: "./init-yt-service.sh"
|
|
chdir: "{{ airflow_worker_dir }}"
|
|
become: yes
|
|
become_user: "{{ ssh_user }}"
|
|
|
|
- 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 -f 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
|
|
|
|
- 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
|
|
|
|
- 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:
|
|
- "docker-compose-ytdlp-ops.yaml"
|
|
state: present
|
|
remove_orphans: true
|