: install/configure gitea

This commit is contained in:
VC
2025-01-29 12:05:43 +01:00
parent b3b234033d
commit 008d4411ad
10 changed files with 264 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
---
- name: Restart Gitea
ansible.builtin.systemd:
name: gitea
enabled: true
daemon_reload: true
state: restarted

View File

@@ -0,0 +1,75 @@
---
- name: Install prerequisites
ansible.builtin.package:
name: git
state: present
update_cache: true
- name: Download Gitea executable
ansible.builtin.get_url:
url: "{{ gitea_url }}"
dest: "{{ gitea_bin }}"
owner: root
group: root
mode: "0o755"
force: true
notify:
- Restart Gitea
- name: Create git user
ansible.builtin.user:
name: git
password: '*'
comment: "Git Version Control"
home: /home/git
shell: /bin/bash
state: present
- name: Create Gitea base dir
ansible.builtin.file:
state: directory
path: "{{ gitea_path }}"
owner: git
group: git
mode: "0o755"
- name: Create Gitea sub dirs
ansible.builtin.file:
state: directory
path: "{{ gitea_path }}/{{ item }}"
owner: git
group: git
mode: "0o755"
loop:
- custom
- data
- log
- name: Create Gitea config dir
ansible.builtin.file:
state: directory
path: "{{ gitea_etc_path }}"
owner: root
group: git
mode: "0o750"
- name: Create Gitea config file
ansible.builtin.template:
src: app.ini.j2
dest: "{{ gitea_etc_path }}/app.ini"
owner: root
group: git
mode: "0o640"
notify:
- Restart Gitea
- name: Create systemd Gitea file
ansible.builtin.template:
src: gitea.service.j2
dest: /etc/systemd/system/gitea.service
owner: root
group: root
mode: "0o640"
notify:
- Restart Gitea

View File

@@ -0,0 +1,82 @@
APP_NAME = Gitea: Git with a cup of tea
RUN_USER = git
WORK_PATH = /srv/gitea
RUN_MODE = prod
[database]
DB_TYPE = postgres
HOST = 127.0.0.1:5432
NAME = giteadb
USER = gitea
PASSWD = {{ gitea_database_passwd }}
SCHEMA =
SSL_MODE = disable
PATH = /srv/gitea/data/gitea.db
LOG_SQL = false
[repository]
ROOT = /srv/gitea/data/gitea-repositories
[server]
SSH_DOMAIN = giteu.be
DOMAIN = giteu.be
HTTP_PORT = 3000
ROOT_URL = https://giteu.be/
APP_DATA_PATH = /srv/gitea/data
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_JWT_SECRET = {{ gitea_server_lfs_jwt_secret }}
OFFLINE_MODE = true
[lfs]
PATH = /srv/gitea/data/lfs
[mailer]
ENABLED = true
SMTP_ADDR = smtp.libertus.eu
SMTP_PORT = 587
FROM = Gitea <gitea@mateu.be>
USER = {{ smtprelay_login }}
PASSWD = {{ smtprelay_pass }}
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = false
DEFAULT_KEEP_EMAIL_PRIVATE = true
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply.localhost
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false
[cron.update_checker]
ENABLED = false
[session]
PROVIDER = file
[log]
MODE = console
LEVEL = info
ROOT_PATH = /srv/gitea/log
[repository.pull-request]
DEFAULT_MERGE_STYLE = merge
[repository.signing]
DEFAULT_TRUST_MODEL = committer
[security]
INSTALL_LOCK = true
INTERNAL_TOKEN = {{ gitea_security_internal_token }}
PASSWORD_HASH_ALGO = pbkdf2
[oauth2]
JWT_SECRET = {{ gitea_oauth2_jwt_secret }}

View File

@@ -0,0 +1,23 @@
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
Wants=postgresql.service
After=postgresql.service
[Service]
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
# LimitNOFILE=524288:524288
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory={{ gitea_path }}
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
#RuntimeDirectory=gitea
ExecStart={{ gitea_bin }} web --config {{ gitea_etc_path }}/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR={{ gitea_path }}
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,7 @@
---
gitea_version: "1.23.1"
gitea_url: "https://dl.gitea.com/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-amd64"
gitea_bin: "/usr/local/bin/gitea"
gitea_path: "/srv/gitea"
gitea_etc_path: "/etc/gitea"