- Update Ansible playbooks and roles for application deployment - Add new Gitea/Traefik troubleshooting playbooks - Update Docker Compose configurations (base, local, staging, production) - Enhance EncryptedEnvLoader with improved error handling - Add deployment scripts (autossh setup, migration, secret testing) - Update CI/CD workflows and documentation - Add Semaphore stack configuration
140 lines
4.4 KiB
YAML
140 lines
4.4 KiB
YAML
---
|
|
- name: Fix Gitea Traefik Labels
|
|
hosts: production
|
|
gather_facts: yes
|
|
become: no
|
|
|
|
vars:
|
|
gitea_stack_path: "{{ stacks_base_path }}/gitea"
|
|
|
|
tasks:
|
|
- name: Check current Gitea container status
|
|
shell: |
|
|
cd {{ gitea_stack_path }}
|
|
docker compose ps gitea
|
|
args:
|
|
executable: /bin/bash
|
|
register: gitea_status_before
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display current status
|
|
debug:
|
|
msg: "{{ gitea_status_before.stdout_lines }}"
|
|
|
|
- name: Check current Traefik labels
|
|
shell: |
|
|
docker inspect gitea --format '{{ '{{' }}range .Config.Labels{{ '}}' }}{{ '{{' }}.Key{{ '}}' }}={{ '{{' }}.Value{{ '}}' }}{{ '{{' }}\n{{ '}}' }}{{ '{{' }}end{{ '}}' }}' 2>&1 | grep -i traefik || echo "No Traefik labels found"
|
|
register: current_labels
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display current labels
|
|
debug:
|
|
msg: "{{ current_labels.stdout_lines }}"
|
|
|
|
- name: Recreate Gitea container with Traefik labels
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ gitea_stack_path }}"
|
|
state: present
|
|
pull: never
|
|
recreate: always
|
|
remove_orphans: no
|
|
register: gitea_recreate
|
|
|
|
- name: Wait for Gitea to be ready
|
|
wait_for:
|
|
port: 3000
|
|
host: localhost
|
|
timeout: 60
|
|
delegate_to: localhost
|
|
when: gitea_recreate.changed
|
|
ignore_errors: yes
|
|
|
|
- name: Wait for Gitea health check
|
|
shell: |
|
|
for i in {1..30}; do
|
|
if docker exec gitea curl -f http://localhost:3000/api/healthz >/dev/null 2>&1; then
|
|
echo "Gitea is healthy"
|
|
exit 0
|
|
fi
|
|
echo "Waiting for Gitea to be healthy... ($i/30)"
|
|
sleep 2
|
|
done
|
|
echo "Gitea health check timeout"
|
|
exit 1
|
|
args:
|
|
executable: /bin/bash
|
|
register: health_wait
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
when: gitea_recreate.changed
|
|
|
|
- name: Display health wait result
|
|
debug:
|
|
msg: "{{ health_wait.stdout_lines }}"
|
|
when: gitea_recreate.changed
|
|
|
|
- name: Check new Gitea container status
|
|
shell: |
|
|
cd {{ gitea_stack_path }}
|
|
docker compose ps gitea
|
|
args:
|
|
executable: /bin/bash
|
|
register: gitea_status_after
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display new status
|
|
debug:
|
|
msg: "{{ gitea_status_after.stdout_lines }}"
|
|
|
|
- name: Check new Traefik labels
|
|
shell: |
|
|
docker inspect gitea --format '{{ '{{' }}range .Config.Labels{{ '}}' }}{{ '{{' }}.Key{{ '}}' }}={{ '{{' }}.Value{{ '}}' }}{{ '{{' }}\n{{ '}}' }}{{ '{{' }}end{{ '}}' }}' 2>&1 | grep -i traefik || echo "No Traefik labels found"
|
|
register: new_labels
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display new labels
|
|
debug:
|
|
msg: "{{ new_labels.stdout_lines }}"
|
|
|
|
- name: Check Traefik service registration
|
|
shell: |
|
|
docker exec traefik wget -qO- http://localhost:8080/api/http/services 2>&1 | grep -i gitea || echo "Gitea service not found (may take a few seconds to register)"
|
|
register: traefik_service
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display Traefik service registration
|
|
debug:
|
|
msg: "{{ traefik_service.stdout_lines }}"
|
|
|
|
- name: Test external Gitea access
|
|
shell: |
|
|
echo "Testing external access..."
|
|
sleep 5 # Give Traefik time to update
|
|
curl -k -H "User-Agent: Mozilla/5.0" -s -o /dev/null -w "HTTP Status: %{http_code}\n" https://git.michaelschiemer.de/ 2>&1 || echo "Connection failed"
|
|
args:
|
|
executable: /bin/bash
|
|
register: external_test
|
|
ignore_errors: yes
|
|
failed_when: false
|
|
|
|
- name: Display external test result
|
|
debug:
|
|
msg: "{{ external_test.stdout_lines }}"
|
|
|
|
- name: Summary
|
|
debug:
|
|
msg:
|
|
- "=== FIX SUMMARY ==="
|
|
- "Container recreated: {{ 'Yes' if gitea_recreate.changed else 'No' }}"
|
|
- "Traefik labels: {{ 'Fixed' if 'traefik' in new_labels.stdout|lower else 'Still missing' }}"
|
|
- ""
|
|
- "If the issue persists:"
|
|
- "1. Check Traefik logs: cd {{ stacks_base_path }}/traefik && docker compose logs traefik"
|
|
- "2. Verify Traefik can reach Gitea: docker exec traefik ping -c 2 gitea"
|
|
- "3. Check Gitea logs for errors: cd {{ gitea_stack_path }} && docker compose logs gitea"
|