Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Successful in 31s
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 27s
🚀 Build & Deploy Image / Build Runtime Base Image (push) Successful in 13s
🚀 Build & Deploy Image / Run Tests & Quality Checks (push) Has been skipped
Security Vulnerability Scan / Composer Security Audit (push) Has been skipped
🚀 Build & Deploy Image / Build Docker Image (push) Successful in 11s
🚀 Build & Deploy Image / Auto-deploy to Staging (push) Failing after 1m12s
🚀 Build & Deploy Image / Auto-deploy to Production (push) Has been skipped
- fix-gitea-timeouts.yml: Add when conditions to wait_for and uri tasks - Wait for Traefik only if traefik_restart.changed - Wait for Gitea via Traefik only if traefik_restart or gitea_restart changed - fix-gitea-complete.yml: Same fixes as fix-gitea-timeouts.yml - Wait for Traefik only if traefik_restart.changed - Wait for Gitea and service discovery checks only if restart occurred - fix-gitea-traefik-connection.yml: Fix wait and test tasks - Register traefik_restart to track if restart happened - Wait for Traefik only if traefik_restart.changed - Test Gitea via Traefik only if traefik_restart.changed - Update message to reflect actual restart status - update-gitea-traefik-service.yml: Fix pause block - Register traefik_restart to track if restart happened - Wait for Traefik only if traefik_restart.changed This prevents unnecessary blocking when traefik_auto_restart=false and ensures wait/healthcheck tasks only run when a restart actually occurred.
83 lines
2.8 KiB
YAML
83 lines
2.8 KiB
YAML
---
|
|
# Ansible Playbook: Update Gitea Traefik Service with Current IP
|
|
#
|
|
# ⚠️ DEPRECATED: This playbook is no longer needed since Traefik runs in bridge network mode.
|
|
# Service discovery via Docker labels works reliably in bridge mode, so manual IP updates
|
|
# are not required. This playbook is kept for reference only.
|
|
#
|
|
# Purpose: Update Traefik dynamic config with current Gitea container IP
|
|
# Usage:
|
|
# ansible-playbook -i inventory/production.yml playbooks/update-gitea-traefik-service.yml \
|
|
# --vault-password-file secrets/.vault_pass
|
|
|
|
- name: Update Gitea Traefik Service with Current IP
|
|
hosts: production
|
|
vars:
|
|
traefik_stack_path: "{{ stacks_base_path }}/traefik"
|
|
gitea_url: "https://{{ gitea_domain }}"
|
|
|
|
tasks:
|
|
- name: Warn that this playbook is deprecated
|
|
ansible.builtin.fail:
|
|
msg: |
|
|
⚠️ This playbook is DEPRECATED and should not be used.
|
|
Traefik service discovery via Docker labels works reliably in bridge mode.
|
|
If you really need to run this, set traefik_auto_restart=true explicitly.
|
|
when: traefik_auto_restart | default(false) | bool == false
|
|
|
|
- name: Get current Gitea container IP in traefik-public network
|
|
shell: |
|
|
docker inspect gitea | grep -A 10 'traefik-public' | grep IPAddress | head -1 | awk '{print $2}' | tr -d '",'
|
|
register: gitea_ip
|
|
changed_when: false
|
|
|
|
- name: Display Gitea IP
|
|
debug:
|
|
msg: "Gitea container IP: {{ gitea_ip.stdout }}"
|
|
|
|
- name: Create Gitea service configuration with current IP
|
|
copy:
|
|
dest: "{{ traefik_stack_path }}/dynamic/gitea-service.yml"
|
|
content: |
|
|
http:
|
|
services:
|
|
gitea:
|
|
loadBalancer:
|
|
servers:
|
|
- url: http://{{ gitea_ip.stdout }}:3000
|
|
mode: '0644'
|
|
|
|
- name: Restart Traefik to load new configuration
|
|
shell: |
|
|
docker compose -f {{ traefik_stack_path }}/docker-compose.yml restart traefik
|
|
when: traefik_auto_restart | default(false) | bool
|
|
register: traefik_restart
|
|
changed_when: traefik_restart.rc == 0
|
|
|
|
- name: Wait for Traefik to be ready
|
|
pause:
|
|
seconds: 10
|
|
when: traefik_restart.changed | default(false) | bool
|
|
|
|
- name: Test Gitea via Traefik
|
|
uri:
|
|
url: "{{ gitea_url }}/api/healthz"
|
|
method: GET
|
|
status_code: [200]
|
|
validate_certs: false
|
|
timeout: 10
|
|
register: final_test
|
|
retries: 5
|
|
delay: 2
|
|
changed_when: false
|
|
|
|
- name: Display result
|
|
debug:
|
|
msg: |
|
|
Gitea-Traefik connection:
|
|
- Gitea IP: {{ gitea_ip.stdout }}
|
|
- Via Traefik: {{ 'OK' if final_test.status == 200 else 'FAILED' }}
|
|
|
|
Note: This is a temporary fix. The IP will need to be updated if the container restarts.
|
|
|