Files
computer-playbook/roles/sys-front-inj-matomo/tasks/inject.yml
kevinveenbirkenbachandClaude Opus 4.8 192470cf2e fix(sys-front-inj-matomo): treat a 200 error-dict as API-not-ready instead of crashing
Matomo can answer SitesManager queries with HTTP 200 carrying an error dict ({"result":"error",...}) instead of the expected site array; indexing site_check.json[0] then crashed the deploy of every app with tracking enabled (decidim). Route the mapping shape into the existing API-not-ready deferral, keeping the array path untouched. A dict passes Jinja's sequence test, so is mapping is the only reliable discriminator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 17:30:36 +02:00

26 lines
1.0 KiB
YAML

---
- name: "🔎 Check if site {{ domain }} is already registered at Matomo"
uri_retry:
url: "{{ matomo_index_php_url }}?module=API&method=SitesManager.getSitesIdFromSiteUrl&url={{ matomo_site_url }}&format=json&token_auth={{ matomo_effective_token
}}"
method: GET
return_content: true
status_code: 200
validate_certs: true
register: site_check
failed_when: false
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
- name: "🔴 Disable Matomo tracking for '{{ domain }}' (API not ready, reapplied later)"
ansible.builtin.set_fact:
inj_enabled: "{{ inj_enabled | combine({'matomo': false}) }}"
when: >-
site_check.status is not defined or site_check.status != 200
or site_check.json is not defined or site_check.json is mapping
- name: "📝 Register site + inject Matomo tracking for '{{ domain }}'"
ansible.builtin.include_tasks: inject_apply.yml
when: >-
site_check.status is defined and site_check.status == 200
and site_check.json is defined and site_check.json is not mapping