Files
computer-playbook/roles/test-e2e-playwright/tasks/01_setup/orchestrate.yml
kevinveenbirkenbachandClaude Opus 5 f19d5e3477 test(lint): refuse a loop_var that shadows a declared variable
Ansible warns that the name is already in use and carries on. Carrying on is the problem: inside the loop the original value is gone, so every lookup, template and nested include reading that name sees the loop item instead, and the task still reports success. The damage lands in a log nobody greps.

The lint collects every key declared in group_vars and in each role's vars or defaults, then reports any loop_var matching one. A denylist of known-bad names would have found application_id and missed domain, which is the same class in four more places.

All seven existing sites are marked, each with the reason read at the source rather than inferred. The three application_id loops pass the role id as the item, and the include_vars that follows loads that role's own application_id with the same value, so both meanings coincide by construction. The four domain loops hand the vhost to sys-stk-front-proxy, whose tasks read front_proxy_domain from exactly that name, so the shadowing is the interface.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 21:23:17 +02:00

41 lines
1.5 KiB
YAML

---
- name: ✅ Ensure staging base dir exists
ansible.builtin.file:
path: "{{ TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR }}"
state: directory
mode: "0755"
- name: ✅ Ensure reports base dir exists
ansible.builtin.file:
path: "{{ TEST_E2E_PLAYWRIGHT_REPORTS_BASE_DIR }}"
state: directory
mode: "0755"
- name: 🧰 Prepare shared @playwright/test install
ansible.builtin.include_tasks: 01_setup.yml
- name: ▶️ Run Playwright for each detected role
ansible.builtin.include_tasks: 02_run_one.yml
loop: "{{ TEST_E2E_PLAYWRIGHT_APPS }}"
loop_control:
loop_var: application_id # nocheck: loop-var-shadow the item IS the role id, so 02_run_one reads the same value the tested role's own vars declare
label: "{{ application_id }}"
- name: 🔁 Stash first-pass failures for one flake retry
ansible.builtin.set_fact:
_playwright_retry_roles: "{{ _playwright_failures }}"
_playwright_failures: []
when: (_playwright_failures | default([])) | length > 0
- name: 🔁 Retry failed roles once on rotated Tor circuits
ansible.builtin.include_tasks: 02_run_one.yml
loop: "{{ _playwright_retry_roles | default([]) }}"
loop_control:
loop_var: application_id # nocheck: loop-var-shadow same loop body, same identity between item and role id
label: "{{ application_id }} (retry)"
- name: 🛑 Fail if there were Playwright failures
ansible.builtin.fail:
msg: "Playwright failed for roles: {{ _playwright_failures }}"
when: (_playwright_failures | default([])) | length > 0