feat(gitea): Migrate configuration from environment variables to app.ini
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 1m12s
🚀 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
🧊 Warm Docker Build Cache / Refresh Buildx Caches (push) Has been cancelled
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 25s
System Maintenance / Run Ansible System Maintenance (push) Successful in 1m8s
📊 Monitor Workflow Performance / Monitor Workflow Performance (push) Failing after 35s
Security Vulnerability Scan / Composer Security Audit (push) Failing after 27s
Some checks failed
🚀 Build & Deploy Image / Determine Build Necessity (push) Failing after 1m12s
🚀 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
🧊 Warm Docker Build Cache / Refresh Buildx Caches (push) Has been cancelled
Security Vulnerability Scan / Check for Dependency Changes (push) Successful in 25s
System Maintenance / Run Ansible System Maintenance (push) Successful in 1m8s
📊 Monitor Workflow Performance / Monitor Workflow Performance (push) Failing after 35s
Security Vulnerability Scan / Composer Security Audit (push) Failing after 27s
- Move all Gitea configuration from docker-compose.yml environment variables to app.ini - Enable Redis cache with proper connection string format (redis://) - Fix Redis password to use Gitea Redis instance password (gitea_redis_password) instead of application Redis stack password - Add database connection pool settings to prevent timeout errors - Configure Redis for cache, session, and queue using app.ini - Update Ansible task to use correct Redis password for Gitea Redis instance Benefits: - Cache now works correctly (environment variables had a bug in Gitea 1.25) - All settings are versioned in Git - Better maintainability and reliability - Configuration follows Gitea documentation recommendations
This commit is contained in:
@@ -13,47 +13,29 @@
|
||||
msg: "Gitea container does not exist. Please deploy Gitea stack first."
|
||||
when: gitea_exists.rc != 0
|
||||
|
||||
- name: Get database configuration from environment
|
||||
ansible.builtin.shell: |
|
||||
docker compose -f {{ gitea_stack_path }}/docker-compose.yml exec -T {{ gitea_container_name }} env | grep -E "^GITEA__database__" || true
|
||||
register: gitea_db_env
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Parse database configuration
|
||||
# Configuration is now read from Ansible variables or defaults
|
||||
# Since environment variables are removed, we use defaults from docker-compose.yml
|
||||
# (which are hardcoded: POSTGRES_DB=gitea, POSTGRES_USER=gitea, POSTGRES_PASSWORD=gitea_password)
|
||||
- name: Set database configuration (from docker-compose.yml defaults)
|
||||
ansible.builtin.set_fact:
|
||||
gitea_db_type: "{{ (gitea_db_env.stdout | default('') | regex_search('GITEA__database__DB_TYPE=([^\n]+)', '\\1') or ['postgres']) | first }}"
|
||||
gitea_db_host: "{{ (gitea_db_env.stdout | default('') | regex_search('GITEA__database__HOST=([^\n]+)', '\\1') or ['postgres:5432']) | first }}"
|
||||
gitea_db_name: "{{ (gitea_db_env.stdout | default('') | regex_search('GITEA__database__NAME=([^\n]+)', '\\1') or ['gitea']) | first }}"
|
||||
gitea_db_user: "{{ (gitea_db_env.stdout | default('') | regex_search('GITEA__database__USER=([^\n]+)', '\\1') or ['gitea']) | first }}"
|
||||
gitea_db_passwd: "{{ (gitea_db_env.stdout | default('') | regex_search('GITEA__database__PASSWD=([^\n]+)', '\\1') or ['gitea_password']) | first }}"
|
||||
gitea_db_type: "postgres"
|
||||
gitea_db_host: "postgres:5432"
|
||||
gitea_db_name: "gitea"
|
||||
gitea_db_user: "gitea"
|
||||
gitea_db_passwd: "gitea_password"
|
||||
|
||||
- name: Get Gitea server configuration from environment
|
||||
ansible.builtin.shell: |
|
||||
docker compose -f {{ gitea_stack_path }}/docker-compose.yml exec -T {{ gitea_container_name }} env | grep -E "^GITEA__server__" || true
|
||||
register: gitea_server_env
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Parse server configuration
|
||||
- name: Set server configuration from Ansible variables or defaults
|
||||
ansible.builtin.set_fact:
|
||||
gitea_domain_parsed: "{{ (gitea_server_env.stdout | default('') | regex_search('GITEA__server__DOMAIN=([^\n]+)', '\\1') or [gitea_domain | default('git.michaelschiemer.de')]) | first }}"
|
||||
ssh_port_parsed: "{{ (gitea_server_env.stdout | default('') | regex_search('GITEA__server__SSH_PORT=([^\n]+)', '\\1') or ['2222']) | first }}"
|
||||
gitea_domain: "{{ gitea_domain | default('git.michaelschiemer.de') }}"
|
||||
ssh_port: "{{ ssh_port | default('2222') }}"
|
||||
ssh_listen_port: "{{ ssh_listen_port | default('2222') }}"
|
||||
|
||||
- name: Set final configuration variables
|
||||
- name: Set Redis password for Gitea Redis instance
|
||||
ansible.builtin.set_fact:
|
||||
gitea_domain: "{{ gitea_domain_parsed }}"
|
||||
ssh_port: "{{ ssh_port_parsed }}"
|
||||
ssh_listen_port: "{{ ssh_port_parsed }}"
|
||||
|
||||
- name: Extract database host and port
|
||||
ansible.builtin.set_fact:
|
||||
gitea_db_hostname: "{{ gitea_db_host.split(':')[0] }}"
|
||||
gitea_db_port: "{{ (gitea_db_host.split(':')[1]) | default('5432') }}"
|
||||
|
||||
- name: Set Redis password
|
||||
ansible.builtin.set_fact:
|
||||
redis_password: "{{ vault_gitea_redis_password | default(vault_redis_password | default('gitea_redis_password')) }}"
|
||||
# Gitea uses its own Redis instance (gitea-redis) with default password 'gitea_redis_password'
|
||||
# unless vault_gitea_redis_password is explicitly set
|
||||
# Note: vault_redis_password is for the application Redis stack, not Gitea Redis
|
||||
redis_password: "{{ vault_gitea_redis_password | default('gitea_redis_password') }}"
|
||||
|
||||
- name: Generate app.ini from template
|
||||
ansible.builtin.template:
|
||||
@@ -118,14 +100,20 @@
|
||||
========================================
|
||||
Gitea configuration has been updated successfully!
|
||||
|
||||
Changes applied:
|
||||
- Redis cache enabled (persistent, survives container restarts)
|
||||
Configuration migrated to app.ini:
|
||||
- All settings now in app.ini (versioned in Git)
|
||||
- Redis cache enabled (now works correctly in app.ini)
|
||||
- Redis sessions enabled (better performance and scalability)
|
||||
- Redis queue enabled (persistent job processing)
|
||||
- Database connection pooling configured
|
||||
- Connection limits set to prevent "Connection reset by peer" errors
|
||||
- Connection limits set to prevent "Timeout before authentication" errors
|
||||
|
||||
Gitea should now be more stable and perform better with Redis.
|
||||
Benefits:
|
||||
- Cache now works correctly (environment variables had a bug in Gitea 1.25)
|
||||
- All settings are versioned and documented
|
||||
- Better maintainability and reliability
|
||||
|
||||
Gitea should now be more stable and perform better with Redis cache enabled.
|
||||
========================================
|
||||
when: gitea_show_status | default(true) | bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user