From a76ad3195cff6bb3e16aadb65ddcbd91e374c2c2 Mon Sep 17 00:00:00 2001 From: Hermes Agent service account Date: Wed, 5 Aug 2026 16:34:13 -0500 Subject: [PATCH] llm-inference-multimodel: fix verify.yml losing Gemma-stop gate when run with --tags verify discover.yml sets llm_existing_gemma_unit_found, but main.yml imports each phase file with import_tasks + a distinct per-phase tag. Tags on import_tasks apply to the whole file, so --tags verify (a supported, documented way to re-run just this phase) skips discover.yml, leaving the fact undefined. The stop task's 'default(false)' silently no-op'd, so re-running verify alone against a host with Gemma still running would start both new instances on top of it -- the OOM this task exists to prevent. Fix: gather service_facts and set the fact locally in verify.yml too, only when not already defined, so the guard works regardless of which tags were selected. --- .../llm-inference-multimodel/tasks/verify.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ansible/roles/llm-inference-multimodel/tasks/verify.yml b/ansible/roles/llm-inference-multimodel/tasks/verify.yml index 58fad49..f77cb3b 100644 --- a/ansible/roles/llm-inference-multimodel/tasks/verify.yml +++ b/ansible/roles/llm-inference-multimodel/tasks/verify.yml @@ -28,6 +28,28 @@ # works unchanged. If no such unit was found, this is a no-op and the # original WARNING from discover.yml (any Gemma process running outside # systemd) still stands as a human decision point. +# +# BUGFIX (found in production): main.yml imports each phase file with +# import_tasks + a per-phase tag (tags: [discover], tags: [verify], ...). +# Tags on import_tasks apply to every task inside that file, so running +# `--tags verify` alone — a normal, supported way to re-run just this +# phase per the header comment in main.yml — skips discover.yml entirely. +# llm_existing_gemma_unit_found was then simply undefined, and the +# `| default(false)` on this task's `when:` silently swallowed that, +# defeating the whole point of this fix: --tags verify against a host +# with Gemma still running would go straight to starting both new +# services on top of it, the exact OOM scenario this task exists to +# prevent. Gather the fact locally here too so this task is correct +# regardless of which tags were requested. +- name: Gather service facts (systemd unit inventory) — ensure available even if discover.yml's tag wasn't selected + ansible.builtin.service_facts: + when: llm_existing_gemma_unit_found is not defined + +- name: Determine whether a systemd unit matching the existing Gemma service exists (if not already known from discover.yml) + ansible.builtin.set_fact: + llm_existing_gemma_unit_found: "{{ (llm_existing_gemma_service_name_guess + '.service') in ansible_facts.services }}" + when: llm_existing_gemma_unit_found is not defined + - name: Stop pre-existing Gemma llama-server before starting new instances (avoid double VRAM usage / OOM) ansible.builtin.systemd: name: "{{ llm_existing_gemma_service_name_guess }}"