diff --git a/roles/sys-ctl-alm-compose/tasks/01_core.yml b/roles/sys-ctl-alm-compose/tasks/01_core.yml index 31983949b5..158172e6f3 100644 --- a/roles/sys-ctl-alm-compose/tasks/01_core.yml +++ b/roles/sys-ctl-alm-compose/tasks/01_core.yml @@ -39,4 +39,4 @@ state: started when: - MODE_ASSERT_LOCAL | bool - - not (_service_loader_preloading | default(false) | bool) + - not (service_loader_preloading | default(false) | bool) diff --git a/roles/sys-service-loader/tasks/list_or_shoot.yml b/roles/sys-service-loader/tasks/list_or_shoot.yml index 3a6d1f1aa0..72665db1d6 100644 --- a/roles/sys-service-loader/tasks/list_or_shoot.yml +++ b/roles/sys-service-loader/tasks/list_or_shoot.yml @@ -1,7 +1,7 @@ --- # Route a list of role names through the service-loader queue when inside a # preload context, otherwise include them immediately. Encapsulates the -# `_service_loader_preloading`-aware branching so callers can stay terse. +# `service_loader_preloading`-aware branching so callers can stay terse. # # Usage: # - include_role: @@ -13,8 +13,8 @@ # - sys-ctl-hlth-container # # - During the preload pass driven by sys-service-loader -# (`_service_loader_preloading: true`), the names are appended to -# `_service_loader_post_run` for the loader's post-load flush. +# (`service_loader_preloading: true`), the names are appended to +# `service_loader_post_run` for the loader's post-load flush. # - Outside any preload pass, the roles are included on the spot, so the # helper is a no-op compared with a direct `include_role` loop. This is # the standalone fallback when the service-loader is bypassed (tests, @@ -22,9 +22,9 @@ - name: "List post-load roles for service-loader flush" ansible.builtin.set_fact: - _service_loader_post_run: "{{ _service_loader_post_run + list_or_shoot_roles }}" + service_loader_post_run: "{{ (service_loader_post_run | default([])) + list_or_shoot_roles }}" changed_when: false - when: (_service_loader_preloading | default(false) | bool) + when: (service_loader_preloading | default(false) | bool) - name: "Shoot post-load roles directly (no preload context active)" ansible.builtin.include_role: @@ -32,4 +32,4 @@ loop: "{{ list_or_shoot_roles }}" loop_control: loop_var: list_or_shoot_role - when: not (_service_loader_preloading | default(false) | bool) + when: not (service_loader_preloading | default(false) | bool) diff --git a/roles/sys-service-loader/tasks/load_service.yml b/roles/sys-service-loader/tasks/load_service.yml index 4f7b68b31f..9d673e9eac 100644 --- a/roles/sys-service-loader/tasks/load_service.yml +++ b/roles/sys-service-loader/tasks/load_service.yml @@ -3,7 +3,7 @@ block: - name: "Mark shared service preload context for {{ service_key }}" ansible.builtin.set_fact: - _service_loader_preloading: true + service_loader_preloading: true changed_when: false - name: "Load {{ service_key }} (Once)" @@ -16,5 +16,5 @@ always: - name: "Clear shared service preload context for {{ service_key }}" ansible.builtin.set_fact: - _service_loader_preloading: false + service_loader_preloading: false changed_when: false diff --git a/roles/sys-service-loader/tasks/main.yml b/roles/sys-service-loader/tasks/main.yml index 8d27347e23..cb76e2f89a 100644 --- a/roles/sys-service-loader/tasks/main.yml +++ b/roles/sys-service-loader/tasks/main.yml @@ -9,17 +9,12 @@ # # Two-phase contract: # 1. Preload pass — iterate `_ordered_services` in dependency order and -# load each service body once (`_service_loader_preloading: true`). -# 2. Post-load pass — flush the `_service_loader_post_run` queue that +# load each service body once (`service_loader_preloading: true`). +# 2. Post-load pass — flush the `service_loader_post_run` queue that # roles registered during preload via this role's `list_or_shoot.yml`. -# Tasks listed there run with `_service_loader_preloading: false`, +# Tasks listed there run with `service_loader_preloading: false`, # so they see the fully preloaded service graph. -- name: "Reset service-loader post-load queue" - ansible.builtin.set_fact: - _service_loader_post_run: [] - changed_when: false - - name: "Discover ordered shared services" ansible.builtin.set_fact: _ordered_services: >- @@ -50,6 +45,6 @@ - name: "Run service-loader post-load roles" ansible.builtin.include_role: name: "{{ post_run_role }}" - loop: "{{ _service_loader_post_run | unique }}" + loop: "{{ service_loader_post_run | unique }}" loop_control: loop_var: post_run_role diff --git a/tasks/stages/01_constructor.yml b/tasks/stages/01_constructor.yml index d05c15c2f8..3dd16204d1 100644 --- a/tasks/stages/01_constructor.yml +++ b/tasks/stages/01_constructor.yml @@ -151,6 +151,12 @@ 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 registry + NFS clients (MUST precede Preload)" ansible.builtin.include_tasks: "./tasks/groups/{{ role_group }}-roles.yml" loop: