---
- name: "π Resolve the node and container of {{ application_id }}"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: libretranslate-engine
resolve_output_prefix: LIBRETRANSLATE_ENGINE
resolve_compose_cid: "{{ LIBRETRANSLATE_ENGINE_CONTAINER_ADDRESS }}"
- name: "π₯ Install the Argos models into {{ application_id }}"
ansible.builtin.shell:
cmd: >- # nocheck: raw-docker, container-exec-resolver the models belong to the served container's own interpreter and land in its mounted model directory, which no other host has
container exec {{ LIBRETRANSLATE_ENGINE_LOCAL_CID }}
sh -c 'PYTHONPATH=. REQUESTS_CA_BUNDLE={{ LIBRETRANSLATE_ENGINE_CA_BUNDLE }}
./venv/bin/python scripts/prefetch_models.py
--directions {{ LIBRETRANSLATE_ENGINE_DIRECTIONS }}
{{ ("--load_only_lang_codes " ~ LIBRETRANSLATE_ENGINE_LOAD_ONLY) if LIBRETRANSLATE_ENGINE_LOAD_ONLY else "" }}'
environment:
CONTAINER_EXEC_TIMEOUT: "{{ LIBRETRANSLATE_ENGINE_PREFETCH_TIMEOUT }}"
register: libretranslate_engine_install
retries: "{{ LIBRETRANSLATE_ENGINE_PREFETCH_RETRIES | int }}"
delay: 15
until: libretranslate_engine_install.rc == 0
changed_when: "'Installed' in libretranslate_engine_install.stdout"
notify: container-recreate
delegate_to: "{{ LIBRETRANSLATE_ENGINE_HOST_NODE }}"
- name: "πΏ Recreate {{ application_id }} so it reads the installed models"
ansible.builtin.meta: flush_handlers