Files
michaelschiemer/deployment/ansible/playbooks/verify-production.yml
Michael Schiemer 36ef2a1e2c
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 10m14s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Has been skipped
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Has been skipped
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
Security Vulnerability Scan / Check for Dependency Changes (push) Failing after 11m25s
Security Vulnerability Scan / Composer Security Audit (push) Has been cancelled
fix: Gitea Traefik routing and connection pool optimization
- Remove middleware reference from Gitea Traefik labels (caused routing issues)
- Optimize Gitea connection pool settings (MAX_IDLE_CONNS=30, authentication_timeout=180s)
- Add explicit service reference in Traefik labels
- Fix intermittent 504 timeouts by improving PostgreSQL connection handling

Fixes Gitea unreachability via git.michaelschiemer.de
2025-11-09 14:46:15 +01:00

137 lines
5.6 KiB
YAML

---
- name: Verify Production Environment
hosts: production
become: no
gather_facts: yes
vars:
# All deployment variables are now defined in group_vars/production.yml
tasks:
- name: Debug - Show variables
debug:
msg:
- "app_stack_path: {{ app_stack_path | default('NOT SET') }}"
- "postgresql_production_stack_path: {{ postgresql_production_stack_path | default('NOT SET') }}"
when: false # Disable by default, enable for debugging
- name: Check if PostgreSQL-Production Stack exists
stat:
path: "{{ postgresql_production_stack_path }}"
register: postgresql_production_stack_dir
- name: Fail if PostgreSQL-Production Stack doesn't exist
fail:
msg: "PostgreSQL-Production Stack not found at {{ postgresql_production_stack_path }}"
when: not postgresql_production_stack_dir.stat.exists
- name: Check PostgreSQL-Production container status
shell: |
docker compose -f {{ postgresql_production_stack_path }}/docker-compose.yml ps postgres-production 2>/dev/null | grep -Eiq "Up|running" || echo "not_running"
register: postgresql_production_status
changed_when: false
failed_when: false
- name: Display PostgreSQL-Production status
debug:
msg: "PostgreSQL-Production: {{ 'RUNNING' if 'Up' in postgresql_production_status.stdout or 'running' in postgresql_production_status.stdout else 'NOT RUNNING' }}"
- name: Verify PostgreSQL-Production connection
shell: |
docker exec postgres-production pg_isready -U postgres -d michaelschiemer 2>/dev/null || echo "not_ready"
register: postgresql_production_ready
changed_when: false
failed_when: false
when: "'Up' in postgresql_production_status.stdout or 'running' in postgresql_production_status.stdout"
- name: Display PostgreSQL-Production connection status
debug:
msg: "PostgreSQL-Production Connection: {{ 'READY' if 'accepting connections' in postgresql_production_ready.stdout else 'NOT READY' }}"
when: postgresql_production_ready is defined
- name: Check if Production Application Stack exists
stat:
path: "{{ app_stack_path | default(stacks_base_path + '/production') }}"
register: production_stack_dir
- name: Fail if Production Application Stack doesn't exist
fail:
msg: "Production Application Stack not found at {{ app_stack_path | default(stacks_base_path + '/production') }}"
when: not production_stack_dir.stat.exists
- name: Check production application container status
shell: |
docker ps --format "{{ '{{' }}.Names{{ '}}' }}" | grep -E "^(app|php)" | head -1 || echo "not_running"
register: production_app_container
changed_when: false
failed_when: false
- name: Display production application container status
debug:
msg: "Production App Container: {{ production_app_container.stdout if production_app_container.stdout != 'not_running' else 'NOT RUNNING' }}"
- name: Verify Networks
shell: |
docker network ls --format "{{ '{{' }}.Name{{ '}}' }}" | grep -E "(traefik-public|postgres-production-internal|app-internal)" || echo "networks_missing"
register: networks_status
changed_when: false
failed_when: false
- name: Display Networks status
debug:
msg: "{{ networks_status.stdout_lines }}"
- name: Test Network connectivity from production app to postgres-production
shell: |
docker exec {{ production_app_container.stdout }} nc -zv postgres-production 5432 2>&1 || echo "connection_failed"
register: network_test
changed_when: false
failed_when: false
when: production_app_container.stdout != 'not_running'
- name: Display Network connectivity status
debug:
msg: "Network connectivity: {{ 'SUCCESS' if 'succeeded' in network_test.stdout or 'open' in network_test.stdout else 'FAILED' }}"
when: network_test is defined
- name: Basic Health Check
uri:
url: "https://michaelschiemer.de/health"
method: GET
validate_certs: no
status_code: [200, 404, 502, 503]
timeout: 10
register: basic_health_check
ignore_errors: yes
- name: Display Basic Health Check status
debug:
msg: "Basic Health Check: {{ 'SUCCESS' if basic_health_check.status == 200 else 'FAILED - Status: ' + (basic_health_check.status|string) }}"
- name: Extended Health Check
uri:
url: "https://michaelschiemer.de/admin/health/api/summary"
method: GET
validate_certs: no
status_code: [200, 404, 502, 503]
timeout: 10
register: extended_health_check
ignore_errors: yes
- name: Display Extended Health Check status
debug:
msg: "Extended Health Check: {{ 'SUCCESS' if extended_health_check.status == 200 else 'NOT AVAILABLE' }}"
when: extended_health_check.status is defined
- name: Display verification summary
debug:
msg:
- "=========================================="
- "Production Verification Summary"
- "=========================================="
- "PostgreSQL-Production: {{ 'RUNNING' if 'Up' in postgresql_production_status.stdout or 'running' in postgresql_production_status.stdout else 'NOT RUNNING' }}"
- "Production App: {{ production_app_container.stdout if production_app_container.stdout != 'not_running' else 'NOT RUNNING' }}"
- "Basic Health Check: {{ 'SUCCESS' if basic_health_check.status == 200 else 'FAILED' }}"
- "=========================================="