--- - name: Check Production Server Status hosts: production gather_facts: yes become: no tasks: - name: Check server uptime and basic info shell: | echo "=== Server Uptime ===" uptime echo "" echo "=== Disk Space ===" df -h echo "" echo "=== Memory Usage ===" free -h echo "" echo "=== Docker Status ===" docker --version || echo "Docker not found" docker ps || echo "Docker not running" args: executable: /bin/bash register: server_info ignore_errors: yes failed_when: false - name: Display server info debug: msg: "{{ server_info.stdout_lines }}" - name: Check all Docker stacks status shell: | echo "=== Traefik Stack ===" cd ~/deployment/stacks/traefik && docker compose ps 2>&1 || echo "Traefik stack not found or not running" echo "" echo "=== Application Stack ===" cd ~/deployment/stacks/application && docker compose ps 2>&1 || echo "Application stack not found or not running" echo "" echo "=== PostgreSQL Stack ===" cd ~/deployment/stacks/postgresql && docker compose ps 2>&1 || echo "PostgreSQL stack not found or not running" echo "" echo "=== Monitoring Stack ===" cd ~/deployment/stacks/monitoring && docker compose ps 2>&1 || echo "Monitoring stack not found or not running" echo "" echo "=== Gitea Stack ===" cd ~/deployment/stacks/gitea && docker compose ps 2>&1 || echo "Gitea stack not found or not running" echo "" echo "=== Registry Stack ===" cd ~/deployment/stacks/registry && docker compose ps 2>&1 || echo "Registry stack not found or not running" args: executable: /bin/bash register: stacks_status ignore_errors: yes failed_when: false - name: Display stacks status debug: msg: "{{ stacks_status.stdout_lines }}" - name: Check Traefik logs for errors shell: | cd ~/deployment/stacks/traefik echo "=== Traefik Logs (Last 30 lines) ===" docker compose logs --tail=30 traefik 2>&1 | tail -30 || echo "Could not read Traefik logs" args: executable: /bin/bash register: traefik_logs ignore_errors: yes failed_when: false - name: Display Traefik logs debug: msg: "{{ traefik_logs.stdout_lines }}" - name: Check Application stack logs shell: | cd ~/deployment/stacks/application echo "=== Application Nginx Logs (Last 20 lines) ===" docker compose logs --tail=20 web 2>&1 | tail -20 || echo "Could not read web logs" echo "" echo "=== Application PHP Logs (Last 20 lines) ===" docker compose logs --tail=20 php 2>&1 | tail -20 || echo "Could not read PHP logs" args: executable: /bin/bash register: app_logs ignore_errors: yes failed_when: false - name: Display application logs debug: msg: "{{ app_logs.stdout_lines }}" - name: Test HTTP connectivity shell: | echo "=== Testing HTTP Connectivity ===" echo "Test 1: HTTPS to michaelschiemer.de" curl -k -H "User-Agent: Mozilla/5.0" -s -o /dev/null -w "HTTP %{http_code}\n" https://michaelschiemer.de/health || echo "Connection failed" echo "" echo "Test 2: Direct localhost" curl -k -H "User-Agent: Mozilla/5.0" -s -o /dev/null -w "HTTP %{http_code}\n" https://localhost/health || echo "Connection failed" args: executable: /bin/bash register: http_tests ignore_errors: yes failed_when: false - name: Display HTTP test results debug: msg: "{{ http_tests.stdout_lines }}" - name: Check network connectivity shell: | echo "=== Network Interfaces ===" ip addr show | grep -E "(inet |state)" | head -10 echo "" echo "=== Docker Networks ===" docker network ls echo "" echo "=== Traefik Network Connectivity ===" docker network inspect traefik-public 2>&1 | grep -E "(Name|Subnet|Containers)" | head -10 || echo "Traefik network not found" args: executable: /bin/bash register: network_info ignore_errors: yes failed_when: false - name: Display network info debug: msg: "{{ network_info.stdout_lines }}" - name: Check firewall status shell: | echo "=== Firewall Status ===" sudo ufw status || echo "UFW not installed or not configured" echo "" echo "=== Listening Ports ===" sudo netstat -tlnp | grep -E "(80|443|8080|3000)" | head -10 || ss -tlnp | grep -E "(80|443|8080|3000)" | head -10 || echo "Could not check listening ports" args: executable: /bin/bash register: firewall_info ignore_errors: yes failed_when: false - name: Display firewall info debug: msg: "{{ firewall_info.stdout_lines }}"