From 5285f4c241104385b6a4c0234536c5bf9aafe3e8 Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Thu, 23 Apr 2026 11:52:32 +0300 Subject: [PATCH] debug: Add comprehensive debugging for drift detection and JSON POSTing - Add debug output showing rsyslogd_check.diff structure - Simplify file extraction logic for rsyslog.d directory changes - Show full JSON payload before sending to API - Add connectivity test to gitops-status-server before POST - Show curl command and response codes for debugging - Display warning if OUT_OF_SYNC but no files extracted This helps diagnose why drift is detected but files aren't listed in the JSON. --- ansible/playbooks/drift-check.yml | 27 +++++++++++++++++++-------- update-gitops-status.sh | 6 ++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ansible/playbooks/drift-check.yml b/ansible/playbooks/drift-check.yml index 138ccea..e12d733 100644 --- a/ansible/playbooks/drift-check.yml +++ b/ansible/playbooks/drift-check.yml @@ -102,6 +102,15 @@ msg: "rsyslogd_check details: {{ rsyslogd_check }}" when: rsyslogd_check.changed + - name: Debug rsyslogd_check.diff structure + ansible.builtin.debug: + msg: | + rsyslogd_check.diff is list: {{ rsyslogd_check.diff is iterable and rsyslogd_check.diff is not string }} + rsyslogd_check.diff length: {{ rsyslogd_check.diff | length if rsyslogd_check.diff is iterable else 'N/A' }} + rsyslogd_check.diff first item: {{ rsyslogd_check.diff[0] if rsyslogd_check.diff is iterable and rsyslogd_check.diff | length > 0 else 'empty' }} + Full diff content: {{ rsyslogd_check.diff }} + when: rsyslogd_check.changed and rsyslogd_check.diff is defined + # ───────────────────────────────────────────────────────────────────────── # Build structured list of changed files for GitOps status server # This data is parsed by the update-gitops-status.sh wrapper script @@ -115,17 +124,19 @@ drifted_files: "{{ drifted_files + ['/etc/rsyslog.conf'] }}" when: main_config_check.changed - - name: Extract specific rsyslog.d files that changed + - name: Debug rsyslogd_check structure + ansible.builtin.debug: + msg: "rsyslogd_check.diff type: {{ rsyslogd_check.diff is iterable }}, content: {{ rsyslogd_check.diff }}" + when: rsyslogd_check.changed and rsyslogd_check.diff is defined + + - name: Mark rsyslog.d directory as changed (simplified) ansible.builtin.set_fact: - changed_rsyslogd_files: "{{ rsyslogd_check.diff | map(attribute='dest') | list if rsyslogd_check.diff is defined else [] }}" + drifted_files: "{{ drifted_files + ['/etc/rsyslog.d/'] }}" when: rsyslogd_check.changed - - name: Add changed rsyslog.d files to drifted list - ansible.builtin.set_fact: - drifted_files: "{{ drifted_files + changed_rsyslogd_files }}" - when: - - rsyslogd_check.changed - - changed_rsyslogd_files is defined and changed_rsyslogd_files | length > 0 + - name: Debug changed files list after rsyslog.d check + ansible.builtin.debug: + msg: "Drifted files after rsyslog.d: {{ drifted_files }}" - name: Add missing files to drifted list ansible.builtin.set_fact: diff --git a/update-gitops-status.sh b/update-gitops-status.sh index ec5a71c..013c632 100644 --- a/update-gitops-status.sh +++ b/update-gitops-status.sh @@ -221,6 +221,12 @@ echo "" echo "Step 4/4: Sending status to gitops-status-server..." echo " URL: $GITOPS_STATUS_SERVER_URL/api/status" echo " Method: POST" +echo " Request Payload:" +echo "$STATUS_JSON" | jq '.' 2>/dev/null | sed 's/^/ /' || echo "$STATUS_JSON" | sed 's/^/ /' +echo "" +echo "Step 4/4: Sending status to gitops-status-server..." +echo " URL: $GITOPS_STATUS_SERVER_URL/api/status" +echo " Method: POST" echo " Payload size: $(echo "$STATUS_JSON" | wc -c) bytes" echo "" echo " ========== JSON PAYLOAD BEING SENT =========="