--- - name: Check Docker Compose Logs for JSON Output hosts: production gather_facts: yes become: no tasks: - name: Get recent docker compose logs for staging-app (JSON format check) shell: | cd ~/deployment/stacks/staging echo "=== Last 100 lines of staging-app logs ===" docker compose logs --tail=100 staging-app 2>&1 | tail -50 echo "" echo "=== Checking for JSON logs ===" docker compose logs --tail=200 staging-app 2>&1 | grep -E '^{"|^\{' | head -5 || echo "No JSON logs found (or logs are in plain text)" args: executable: /bin/bash register: compose_logs ignore_errors: yes failed_when: false - name: Display compose logs debug: msg: "{{ compose_logs.stdout_lines }}" - name: Get all recent logs from all staging services shell: | cd ~/deployment/stacks/staging echo "=== All staging services logs (last 30 lines each) ===" docker compose logs --tail=30 2>&1 args: executable: /bin/bash register: all_logs ignore_errors: yes failed_when: false - name: Display all logs debug: msg: "{{ all_logs.stdout_lines }}" when: all_logs.stdout_lines is defined