--- - name: Final fix for App1 Nginx configuration hosts: 192.168.0.110 become: yes tasks: - name: Deploy final Nginx configuration template: src: "/root/projects/ansible-config/roles/nginx/templates/app1.conf.j2" dest: /etc/nginx/conf.d/app1.conf owner: root group: root mode: '0644' - name: Test Nginx configuration command: nginx -t register: nginx_test changed_when: false - name: Show test result debug: msg: "{{ nginx_test.stdout_lines }}" - name: Reload Nginx systemd: name: nginx state: reloaded when: nginx_test.rc == 0 - name: Test all endpoints shell: | echo "=== Testing endpoints ===" for endpoint in /api/test /health /status /nginx_status; do echo -n "$endpoint: " curl -s -o /dev/null -w "%{http_code}" http://localhost$endpoint && echo " OK" || echo " FAILED" done register: endpoint_test changed_when: false - name: Show endpoint test results debug: msg: "{{ endpoint_test.stdout_lines }}" - name: Verify endpoints return JSON shell: | echo "=== Checking JSON responses ===" curl -s http://localhost/api/test | python3 -m json.tool && echo "API Test: OK" || echo "API Test: FAILED" curl -s http://localhost/health | python3 -m json.tool && echo "Health: OK" || echo "Health: FAILED" register: json_test changed_when: false ignore_errors: yes - name: Final status check debug: msg: | ✅ App1 Nginx configuration fixed! 🌐 Access: http://192.168.0.110 📊 Status: http://192.168.0.110/status 🔧 API Test: http://192.168.0.110/api/test 💚 Health: http://192.168.0.110/health 📈 Node metrics: http://192.168.0.110:9100/metrics