Skip to main content

Ansible Role: SCM

Software Code Management role. Currently installs and manages Gitea on Debian and Ubuntu systems. The role downloads a versioned upstream binary, keeps a previous version for quick rollback via a symlink, creates a dedicated system user, writes app.ini fully from variables, and manages the systemd unit.

Requirements​

This role requires Ansible 2.12 or higher. The target system should be Debian or Ubuntu.

Role Variables​

The following variables are defined in defaults/main.yml:

VariableDescriptionDefault Value
gitea_nameService name (used for binary, unit, paths)gitea
gitea_versionGitea version to install (no leading v)1.25.5
gitea_archArchitecture suffix of the upstream releaseamd64
gitea_optInstall directory (holds versioned binaries + symlink)/opt/{{ gitea_name }}
gitea_etcConfig directory (app.ini lives here)/etc/{{ gitea_name }}
gitea_homeData directory / WorkingDirectory/var/lib/{{ gitea_name }}
gitea_urlFull download URL of the linux-<arch> binaryupstream GitHub release URL
gitea_keep_versionsPrevious versioned binaries to keep for rollback1
gitea_user_createWhether this role should create the system user/grouptrue
gitea_user / gitea_groupService user and groupgit / git
gitea_uid / gitea_gidOptional fixed uid/gidunset (system-assigned)
gitea_user_homeHome directory for the service user/home/{{ gitea_user }}
gitea_user_shellLogin shell for the service user/bin/bash
gitea_app_iniDict rendered verbatim into app.iniminimal sqlite3 defaults

About gitea_app_ini​

app.ini is fully driven from this dictionary. Keys become INI sections; the reserved key DEFAULT is rendered at the top of the file without a section header (matching Gitea's convention). Section names with dots (e.g. cron.update_checker, repository.signing) are preserved verbatim. Override this dict in your playbook to inject any setting Gitea supports.

Dependencies​

None.

Example Playbook​

- hosts: gitea_servers
roles:
- role: ansible_role_scm
vars:
gitea_version: '1.25.5'
gitea_user: 'git'
gitea_app_ini:
DEFAULT:
APP_NAME: 'My Gitea'
RUN_USER: 'git'
WORK_PATH: '/var/lib/gitea'
RUN_MODE: 'prod'
server:
DOMAIN: 'git.example.com'
HTTP_PORT: 3000
ROOT_URL: 'https://git.example.com/'
DISABLE_SSH: true
database:
DB_TYPE: 'postgres'
HOST: '127.0.0.1:5432'
NAME: 'giteadb'
USER: 'gitea'
PASSWD: '{{ vault_gitea_db_password }}'
SSL_MODE: 'disable'
security:
INSTALL_LOCK: true
INTERNAL_TOKEN: '{{ vault_gitea_internal_token }}'

License​

GPL-3.0-only

Author Information​