yt-dlp-dags/ansible/playbooks/restart_worker.yml

54 lines
1.6 KiB
YAML

---
- name: Restart and Update ytdlp-ops Worker
hosts: all:!af-green
vars:
# This should be the root directory of your project on the target worker machine.
project_dir: "{{ '/srv/airflow_master' if inventory_hostname == 'af-green' else '/srv/airflow_dl_worker' }}"
# This is the path to your compose file, relative to the project_dir.
compose_file: "configs/docker-compose-ytdlp-ops.yaml"
# The specific image to pull for updates.
service_image: "pangramia/ytdlp-ops-server:4.0.1"
tasks:
- name: "Ensure project directory exists"
ansible.builtin.file:
path: "{{ project_dir }}"
state: directory
mode: '0755'
become: yes
- name: "Copy get_info_json_client.py to worker"
ansible.builtin.copy:
src: ../../get_info_json_client.py
dest: "{{ project_dir }}/get_info_json_client.py"
mode: '0755'
become: yes
- name: "Pull the latest image for the ytdlp-ops service"
community.docker.docker_image:
name: "{{ service_image }}"
source: pull
tags:
- pull
- name: "Take down the ytdlp-ops services"
community.docker.docker_compose_v2:
project_src: "{{ project_dir }}"
files:
- "{{ compose_file }}"
state: absent
remove_volumes: true
tags:
- down
- name: "Bring up the ytdlp-ops services"
community.docker.docker_compose_v2:
project_src: "{{ project_dir }}"
files:
- "{{ compose_file }}"
state: present
recreate: always # Corresponds to --force-recreate
build: never
tags:
- up