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
- 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
91 lines
3.1 KiB
YAML
91 lines
3.1 KiB
YAML
---
|
|
# Ensure Gitea is Discovered by Traefik
|
|
# This playbook ensures that Traefik properly discovers Gitea after restarts
|
|
- name: Ensure Gitea is Discovered by Traefik
|
|
hosts: production
|
|
gather_facts: no
|
|
become: no
|
|
vars:
|
|
traefik_stack_path: "{{ stacks_base_path }}/traefik"
|
|
gitea_stack_path: "{{ stacks_base_path }}/gitea"
|
|
max_wait_seconds: 60
|
|
check_interval: 5
|
|
|
|
tasks:
|
|
- name: Check if Gitea container is running
|
|
ansible.builtin.shell: |
|
|
cd {{ gitea_stack_path }}
|
|
docker compose ps gitea | grep -q "Up" && echo "RUNNING" || echo "NOT_RUNNING"
|
|
register: gitea_status
|
|
changed_when: false
|
|
|
|
- name: Start Gitea if not running
|
|
ansible.builtin.shell: |
|
|
cd {{ gitea_stack_path }}
|
|
docker compose up -d gitea
|
|
when: gitea_status.stdout == "NOT_RUNNING"
|
|
register: gitea_start
|
|
|
|
- name: Wait for Gitea to be ready
|
|
ansible.builtin.wait_for:
|
|
timeout: 30
|
|
delay: 2
|
|
when: gitea_start.changed | default(false) | bool
|
|
|
|
- name: Check if Traefik can see Gitea container
|
|
ansible.builtin.shell: |
|
|
cd {{ traefik_stack_path }}
|
|
docker compose exec -T traefik sh -c 'wget -qO- http://localhost:8080/api/http/routers 2>&1 | python3 -m json.tool 2>&1 | grep -qi gitea && echo "FOUND" || echo "NOT_FOUND"'
|
|
register: traefik_gitea_check
|
|
changed_when: false
|
|
failed_when: false
|
|
retries: "{{ (max_wait_seconds | int) // (check_interval | int) }}"
|
|
delay: "{{ check_interval }}"
|
|
until: traefik_gitea_check.stdout == "FOUND"
|
|
|
|
- name: Restart Traefik if Gitea not found
|
|
ansible.builtin.shell: |
|
|
cd {{ traefik_stack_path }}
|
|
docker compose restart traefik
|
|
when: traefik_gitea_check.stdout == "NOT_FOUND"
|
|
register: traefik_restart
|
|
|
|
- name: Wait for Traefik to be ready after restart
|
|
ansible.builtin.wait_for:
|
|
timeout: 30
|
|
delay: 2
|
|
when: traefik_restart.changed | default(false) | bool
|
|
|
|
- name: Verify Gitea is reachable via Traefik
|
|
ansible.builtin.uri:
|
|
url: "https://{{ gitea_domain }}/api/healthz"
|
|
method: GET
|
|
status_code: [200]
|
|
validate_certs: false
|
|
timeout: 10
|
|
register: gitea_health_check
|
|
retries: 5
|
|
delay: 2
|
|
until: gitea_health_check.status == 200
|
|
failed_when: false
|
|
|
|
- name: Display result
|
|
ansible.builtin.debug:
|
|
msg: |
|
|
================================================================================
|
|
GITEA TRAEFIK DISCOVERY - RESULT
|
|
================================================================================
|
|
|
|
Gitea Status: {{ gitea_status.stdout }}
|
|
Traefik Discovery: {{ traefik_gitea_check.stdout }}
|
|
Gitea Health Check: {{ 'OK' if (gitea_health_check.status | default(0) == 200) else 'FAILED' }}
|
|
|
|
{% if gitea_health_check.status | default(0) == 200 %}
|
|
✅ Gitea is reachable via Traefik
|
|
{% else %}
|
|
❌ Gitea is not reachable via Traefik
|
|
{% endif %}
|
|
|
|
================================================================================
|
|
|