diff --git a/roles/sys-service-loader/tasks/list_or_shoot.yml b/roles/sys-service-loader/tasks/list_or_shoot.yml index 93988bd020..08fab0241e 100644 --- a/roles/sys-service-loader/tasks/list_or_shoot.yml +++ b/roles/sys-service-loader/tasks/list_or_shoot.yml @@ -24,14 +24,24 @@ ansible.builtin.set_fact: service_loader_post_run: "{{ (service_loader_post_run | default([])) + list_or_shoot_roles }}" changed_when: false + run_once: false when: (service_loader_preloading | default(false) | bool) +- name: "🎯 Shoot the post-load role directly (no preload context active)" + ansible.builtin.include_role: + name: "{{ list_or_shoot_roles | first }}" + vars: + application_id: "{{ list_or_shoot_roles | first }}" + when: + - not (service_loader_preloading | default(false) | bool) + - list_or_shoot_roles | length == 1 + - name: "🎯 Shoot post-load roles directly (no preload context active)" ansible.builtin.include_role: name: "{{ list_or_shoot_role }}" vars: application_id: "{{ list_or_shoot_role }}" - loop: "{{ list_or_shoot_roles }}" + loop: "{{ list_or_shoot_roles if list_or_shoot_roles | length > 1 else [] }}" loop_control: loop_var: list_or_shoot_role when: not (service_loader_preloading | default(false) | bool) diff --git a/roles/sys-service-loader/tasks/main.yml b/roles/sys-service-loader/tasks/main.yml index b7360c5d40..feb6b6de9c 100644 --- a/roles/sys-service-loader/tasks/main.yml +++ b/roles/sys-service-loader/tasks/main.yml @@ -55,6 +55,11 @@ loop_var: service_item label: "{{ service_item.id }}" +- name: "📂 Close the preload context before the post-load flush" + ansible.builtin.set_fact: + service_loader_preloading: false + changed_when: false + - name: "▶️ Run service-loader post-load roles" ansible.builtin.include_role: name: "{{ post_run_role }}" diff --git a/roles/sys-svc-compose/tasks/main.yml b/roles/sys-svc-compose/tasks/main.yml index 6a69e41198..af0c5c4153 100644 --- a/roles/sys-svc-compose/tasks/main.yml +++ b/roles/sys-svc-compose/tasks/main.yml @@ -2,15 +2,12 @@ - include_tasks: 00_core.yml when: run_once_sys_svc_compose is not defined -- name: "🧭 Route docker cleanup/health deps through service-loader" +- name: "🧭 Route the compose hard repair through service-loader" ansible.builtin.include_role: name: sys-service-loader tasks_from: list_or_shoot.yml vars: list_or_shoot_roles: - - sys-ctl-cln-docker - - sys-ctl-hlth-container - - sys-ctl-hlth-volumes - sys-ctl-rpr-container-hard - name: "🧭 Route svc-bkp-volume-2-local through service-loader (when deployed)" diff --git a/roles/sys-svc-container/tasks/00_core.yml b/roles/sys-svc-container/tasks/00_core.yml index 1acdc12f73..d715d4da06 100644 --- a/roles/sys-svc-container/tasks/00_core.yml +++ b/roles/sys-svc-container/tasks/00_core.yml @@ -94,4 +94,14 @@ include_tasks: "03_reset.yml" when: MODE_RESET | bool +- name: "🧭 Route docker cleanup/health deps through service-loader" + ansible.builtin.include_role: + name: sys-service-loader + tasks_from: list_or_shoot.yml + vars: + list_or_shoot_roles: + - sys-ctl-cln-docker + - sys-ctl-hlth-container + - sys-ctl-hlth-volumes + - include_tasks: utils/once/flag.yml diff --git a/tasks/stages/01_constructor.yml b/tasks/stages/01_constructor.yml index bd21b7648f..dc6b768cfc 100644 --- a/tasks/stages/01_constructor.yml +++ b/tasks/stages/01_constructor.yml @@ -191,17 +191,17 @@ }} when: _package_batch_ids | length > 0 -- name: "🥾 Bootstrap svc-swarm-node" - ansible.builtin.include_role: - name: svc-swarm-node - when: "'svc-swarm-node' | application_allowed(group_names, lookup('deployment').whitelist)" - - name: "📂 Open service-loader preload context BEFORE Bootstrap" ansible.builtin.set_fact: service_loader_post_run: [] service_loader_preloading: true changed_when: false +- name: "🥾 Bootstrap svc-swarm-node" + ansible.builtin.include_role: + name: svc-swarm-node + when: "'svc-swarm-node' | application_allowed(group_names, lookup('deployment').whitelist)" + - name: "🥾 Bootstrap NFS clients + registry + sandbox runtimes (MUST precede Preload)" ansible.builtin.include_tasks: ./tasks/utils/setup/group.yml loop: