Files
nult/roles/gitea/tasks/upgrade.yml
Mark a9554f3e5d Initial commit: nult - Ansible deployment toolkit
Merged from veridion-gitea and veridion-act-runner-gitea repos.

nult (Null-T) - instant teleportation from Strugatsky's Noon Universe.
Like Null-T, this toolkit instantly deploys infrastructure.

Roles:
- gitea: Gitea server with PostgreSQL (Docker Compose)
- act_runner: Gitea Actions runner

Playbooks:
- gitea.yml: Deploy Gitea server
- act-runner.yml: Deploy Act Runner
- site.yml: Deploy all services

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 15:34:07 +01:00

68 lines
2.8 KiB
YAML

---
# =============================================================================
# Upgrade Tasks - Deploy New docker-compose.yml
# =============================================================================
#
# Deploys the templated docker-compose.yml with the new Gitea version.
#
# This task uses Ansible's template module to generate docker-compose.yml
# from a Jinja2 template. The template allows us to:
# - Update the Gitea image version
# - Update the PostgreSQL image version
# - Apply configuration from Ansible variables
#
# The template is stored at: roles/gitea/templates/docker-compose.yml.j2
#
# After this task, the docker-compose.yml on the server will reference
# the new image versions, but containers aren't restarted yet.
# That happens in deploy.yml.
# =============================================================================
# -----------------------------------------------------------------------------
# Backup Current docker-compose.yml
# -----------------------------------------------------------------------------
# Even though we have a full gitea dump backup, it's useful to have
# the docker-compose.yml readily available for quick rollback.
- name: Backup current docker-compose.yml before upgrade
ansible.builtin.copy:
src: "{{ gitea_install_dir }}/docker-compose.yml"
dest: "{{ gitea_install_dir }}/docker-compose.yml.backup"
remote_src: true
mode: "0640"
# -----------------------------------------------------------------------------
# Deploy New docker-compose.yml from Template
# -----------------------------------------------------------------------------
# The template module:
# 1. Reads the Jinja2 template (docker-compose.yml.j2)
# 2. Substitutes all {{ variable }} placeholders with actual values
# 3. Writes the result to the destination path
#
# Key variables used in the template:
# gitea_version - Docker image tag (e.g., "1.25")
# postgres_version - PostgreSQL image tag (e.g., "17-alpine")
# gitea_db_password - Database password (from vault)
# gitea_user_uid/gid - Container user/group IDs
# gitea_http_port - Internal HTTP port (3000)
# gitea_ssh_port - Internal SSH port (22)
# gitea_ssh_external_port - External SSH port (2222)
- name: Deploy docker-compose.yml from template
ansible.builtin.template:
src: docker-compose.yml.j2
dest: "{{ gitea_install_dir }}/docker-compose.yml"
mode: "0640"
# Validate the YAML syntax before deploying
validate: "docker compose -f %s config --quiet"
register: gitea_compose_deployed
# Display what changed for operator visibility
- name: Display upgrade info
ansible.builtin.debug:
msg: |
docker-compose.yml updated:
Gitea version: {{ gitea_version }}
PostgreSQL version: {{ gitea_postgres_version }}
Template changed: {{ gitea_compose_deployed.changed }}