l3d.gitea
Ansible Role for Gitea/Forgejo
This role helps you install and manage Gitea or Forgejo. Both provide a simple, self-hosted Git service. Gitea is a lightweight code hosting solution managed by the community and is written in Go. Forgejo is a version of Gitea.
Mirrors
You can find this role on:
How to Use in a Playbook
Here's a sample playbook code that has been tested with the latest Debian Stable. It should also work on Ubuntu and Red Hat.
- name: "Install Gitea"
hosts: git.example.com
roles:
- {role: l3d.gitea, tags: gitea}
vars:
gitea_fqdn: 'git.example.com'
gitea_root_url: 'https://git.example.com'
gitea_protocol: http
gitea_start_ssh: true
Choosing SSH Server
Gitea has a built-in SSH server running on port 2222. By default, this is used, which creates an SSH clone URL of gitea@<fqdn>:2222:<user>/<repo>.git
.
If you prefer a cleaner SSH URL like git@<fqdn>:<user>/<repo>.git
, use the host SSH server with these variable settings:
gitea_ssh_port: 22 # Use the host SSH server's standard port
gitea_user: git # Required to avoid permission issues
gitea_start_ssh: false # Do not start the built-in SSH server
When transferring an existing setup, ensure the standard SSH server runs and that the gitea_user
has proper permissions.
Variables Overview
Choosing Between Gitea and Forgejo
You can decide whether to install Gitea or Forgejo using the gitea_fork
variable:
Variable Name | Default Value | Description |
---|---|---|
gitea_fork |
gitea |
Set to forgejo to install Forgejo instead. |
Update Mechanism
You can specify which version of Gitea to install or use latest
to always grab the most recent one from the Gitea releases.
For Forgejo, it’s better to specify the exact version you want. Check Forgejo releases for valid options like v1.21.5
.
Other Important Variables
gitea_version
: Specify the exact Gitea version or uselatest
.gitea_user
,gitea_home
,gitea_database
, etc.: Various settings for user and directory configurations.
You can fully customize Gitea's settings during installation by adjusting the variables accordingly.
Local Gitea Users
Define local Gitea or Forgejo users using the gitea_users
variable:
Field | Description |
---|---|
name |
User's name |
password |
User's password |
email |
User's email |
admin |
Admin permissions flag |
must_change_password |
Requires a password change on first login |
state |
Set to absent to delete the user |
Customization Options
You can customize your Gitea installation, including uploading a custom logo, footer, and CSS themes.
Requirements
This role relies on ansible.builtin
and community.general
Ansible Collections. For the latest releases, you need the jmespath
package.
Contribution
Feel free to create pull requests, and reach out to me on Mastodon at @[email protected] for any questions or help with issues.
History
This Ansible role started on github.com/thomas-maurice/ansible-role-gitea, and has since been improved for better usability and faster updates. It is part of the l3d.git Collection.
Ansible role to configure and deploy gitea and forgejo, a painless self-hosted Git service.
ansible-galaxy install l3d.gitea