Deploy Gogs as a Podman Quadlet Container
podman- version4.7.2+
gogs_quadlet: (dict) - Define the Container image and taggogs_quadlet_volumes: (list) A list of volumes and paths to be monted on the container.gogs_quadlet_ports: (list) A list of ports to be published by the gogs containergogs_quadlet_psql_volumes: (list) A list of volumes to be mounted on the PostgreSQL container.gogs_quadlet_psql: (dict) Define the PostgreSQL container image and ta to used.gogs_quadlet_psql_ports: (list) List of ports to be published by PostgreSQL containergogs_quadlet_psql_env: (dict) Environment variables binded to the PostgreSQL container.gogs_pod: (dict) Defines the kube pod metadata
container.podman- version1.11.0+
- Basic Gogs Deployment:
deploy gogs and postgresql, postgresql user is the same of GOGS_USER
by default gogs will be deployed and bind volumes from /srv/gogs created on
the host
---
- name: Deploying Gogs
hosts: server
gather_facts: false
vars:
gogs_quadlet_psql_env:
TZ: "ETC/UTC'
POSTGRESQL_PASSWORD: "admin"
GOGS_PASSWORD: "gogs-admin"
GOGS_USER: "gogs"
POSTGRES_DB: "gogs"
roles:
- gogs-quadletcheck-out the default variables from main to see the full list of supported values
This role installs by default a SystemD timer to backup the Gogs.
The backup runs by default every wed at 3:00 AM.
Backups of the gogs-bkp volume are saved in the /srv/gogs/volbkp/ directory.
The backup is generated using the script gogs-bkp.sh,
which is installed in the directory: /usr/local/bin/gogs-bkp.sh.
- Manually Creating a Backup with SystemD:
systemctl start gogs-bkpVolume backup will be saved in /srv/gogs/volbkp/ use
systemctl status gogs-bkp to check the status of the backup job.
- Creating a backup by hand: this command will create a zipped backup of all settings and data
gogs-bkp.sh backup gogs-gogs # gogs-gogs is the container name where gogs is running- Listing the Backups this command will list all backups available in the backup volume
gogs-bkp.sh list gogs-bkp # gogs-bkp is the container backup volume- Restoring a Backup
_to restore a backup generated with the command
gogs-bkp.sh backup, use:
gogs-bkp.sh restore gogs-gogs /backup/my-gogs-backup.zip- Creating a Volume Backup
The backups created with the
gogs-bkp.sh backupcommand are stored in thegogs-bkpvolume, this volume is also recommended to be backed up using thegogs-bkp.sh volbkpcommand:
gogs-bkp.sh volbkp gogs-bkp /tmp # gogs-bkp is the container backup volume_the above command will create a backup of the gogs-bkp volume in the /tmp directory.
- Restoring a Backup
_To restore a volume backup generated with the command
gogs-bkp.sh volbkp, use:
gogs-bkp.sh volrestore gogs-bkp gogs-bkp-2025-10-01_03-00-00.tar.bz2This role was developed using ansible molecule. The use of molecule is optional but recommended.
Note Testing this role with Molecule requires creating local secrets for privilege escalation during the
preparephase. Please read the secret management instructions before runningmoleculecommands.
- Testing:
Unit tests for checking code regression are available in thetestsdirectory. use theverifyortestcommands, e.g:
molecule testwhile developing use verify instead:
molecule create
molecule verify@mrbrandao - Igor Brandão