From b595c1738a40dc79164210a7c281415da99f991c Mon Sep 17 00:00:00 2001 From: MichaelFisher1997 Date: Mon, 2 Mar 2026 14:41:40 +0000 Subject: [PATCH] fix: show detailed Loki template and resource diagnostics --- ansible/roles/observability/tasks/main.yml | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/ansible/roles/observability/tasks/main.yml b/ansible/roles/observability/tasks/main.yml index e36e56e..45d1fe0 100644 --- a/ansible/roles/observability/tasks/main.yml +++ b/ansible/roles/observability/tasks/main.yml @@ -66,19 +66,25 @@ --values /tmp/loki-values.yaml register: loki_template changed_when: false + failed_when: false -- name: Show Loki template output (check for StatefulSet) +- name: Show Loki template summary debug: - msg: "Loki template contains StatefulSet: {{ 'kind: StatefulSet' in loki_template.stdout }}" - when: "'kind: StatefulSet' not in loki_template.stdout" - -- name: Fail if Loki template produces no StatefulSet - fail: msg: | - Loki Helm template produces no StatefulSet. Check values configuration. - Template output (first 100 lines): - {{ loki_template.stdout.split('\n')[:100] | join('\n') }} - when: "'kind: StatefulSet' not in loki_template.stdout" + Template rc: {{ loki_template.rc }} + Contains StatefulSet: {{ 'kind: StatefulSet' in loki_template.stdout }} + Contains Deployment: {{ 'kind: Deployment' in loki_template.stdout }} + Template stderr: {{ loki_template.stderr }} + +- name: Show Loki template output sample + debug: + msg: "{{ loki_template.stdout.split('\n')[:50] }}" + when: loki_template.rc == 0 + +- name: Fail if Loki template fails + fail: + msg: "Loki helm template failed: {{ loki_template.stderr }}" + when: loki_template.rc != 0 - name: Remove legacy Loki scalable workloads (if present) command: >- @@ -145,10 +151,20 @@ changed_when: false failed_when: false +- name: Show ALL observability resources + command: kubectl -n {{ observability_namespace }} get all,configmaps,secrets,pvc + register: all_observability_resources + changed_when: false + failed_when: false + +- name: Debug all observability resources + debug: + msg: "{{ all_observability_resources.stdout }}" + when: all_observability_resources.stdout | length > 0 + - name: Debug Loki resources debug: - msg: "{{ loki_resources.stdout }}" - when: loki_resources.stdout | length > 0 + msg: "Loki resources: {{ loki_resources.stdout if loki_resources.stdout | length > 0 else 'No Loki resources found' }}" - name: Wait for Loki statefulset rollout command: kubectl -n {{ observability_namespace }} rollout status statefulset/loki --timeout=10m