Files
homelab/ansible/roles/semaphore/templates/semaphore-postgres.container.j2
Hermes Agent service account 80f810fb0c feat(semaphore): rewrite role with rootful Podman Quadlet + PostgreSQL
Complete rewrite of the semaphore role. Supersedes three prior
iterations whose admin-user-creation logic was unreliable across
Semaphore CLI versions.

Architecture:
  - Rootful Podman Quadlet under /etc/containers/systemd/
  - Separate PostgreSQL 16-alpine container on a user-defined
    podman network (semaphore-net)
  - Named volumes for both data stores (semaphore_data,
    semaphore_postgres_data) so container recreation is
    non-destructive
  - Pinned image tags: semaphoreui/semaphore:v2.18.5-ansible2.16.5
    and postgres:16-alpine
  - Post-deploy HTTP health check fails the playbook if Semaphore
    doesn't respond on /api/ping within ~60s

Admin user creation remains intentionally manual after first deploy;
the role README documents the exact podman exec command.

Removes the duplicate deploy_semaphore.yml and the now-unneeded
cleanup_semaphore.yml; day1_deploy_semaphore.yml is the canonical
entry point.
2026-05-29 21:34:22 -05:00

38 lines
1.2 KiB
Django/Jinja

# {{ ansible_managed }}
# mk-labs PostgreSQL backing store for SemaphoreUI
# Managed by Ansible - semaphore role
[Unit]
Description=PostgreSQL for SemaphoreUI
After=network-online.target
Wants=network-online.target
[Container]
Image={{ semaphore_postgres_image }}
ContainerName={{ semaphore_postgres_container_name }}
Network={{ semaphore_network_name }}
# Persistent data on a named volume. :Z relabels for SELinux; :U maps
# ownership for rootless. Rootful + ext4 doesn't strictly require either,
# but keeping them is harmless and portable.
Volume={{ semaphore_postgres_volume }}:/var/lib/postgresql/data:Z
Environment=POSTGRES_USER={{ semaphore_db_user }}
Environment=POSTGRES_DB={{ semaphore_db_name }}
Environment=POSTGRES_PASSWORD={{ semaphore_db_password }}
# Initialise the locale and encoding deterministically
Environment=POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
# Healthcheck — systemd doesn't act on this, but it's useful diagnostically
HealthCmd=pg_isready -U {{ semaphore_db_user }} -d {{ semaphore_db_name }}
HealthInterval=10s
HealthTimeout=5s
HealthRetries=3
[Service]
Restart=always
TimeoutStartSec=120
[Install]
WantedBy=multi-user.target default.target