[fix] gitea/forgejo files

This commit is contained in:
Christian Fraß 2024-07-10 15:36:32 +02:00
parent f95cc6498a
commit 4a60e78e8f
15 changed files with 118 additions and 118 deletions

View file

@ -1,5 +1,5 @@
{
"var_authelia_for_gitea_gitea_url_base": "https://gitea.example.org",
"var_authelia_for_gitea_client_id": "gitea",
"var_authelia_for_gitea_client_secret": "REPLACE_ME"
"var_authelia_for_forgejo_forgejo_url_base": "https://forgejo.example.org",
"var_authelia_for_forgejo_client_id": "forgejo",
"var_authelia_for_forgejo_client_secret": "REPLACE_ME"
}

View file

@ -1,9 +1,9 @@
## Beschreibung
Um [Gitea](../gitea) gegen [Authelia](../authelia) authentifizieren zu lassen
Um [Gitea](../forgejo) gegen [Authelia](../authelia) authentifizieren zu lassen
## Verweise
- [Gitea-Dokumentation | Configuration | OpenID](https://docs.gitea.com/administration/config-cheat-sheet#openid-openid)
- [Authelia-Dokumentation | Gitea Integration](https://www.authelia.com/integration/openid-connect/gitea/)
- [Gitea-Dokumentation | Configuration | OpenID](https://docs.forgejo.com/administration/config-cheat-sheet#openid-openid)
- [Authelia-Dokumentation | Gitea Integration](https://www.authelia.com/integration/openid-connect/forgejo/)

View file

@ -4,7 +4,7 @@
"become": true,
"ansible.builtin.template": {
"src": "authelia-client-conf.json.j2",
"dest": "/etc/authelia/conf.d/clients/gitea.json"
"dest": "/etc/authelia/conf.d/clients/forgejo.json"
}
},
{

View file

@ -1,11 +1,11 @@
{
"client_id": "{{var_authelia_for_gitea_client_id}}",
"client_secret": "{{var_authelia_for_gitea_client_secret}}",
"client_id": "{{var_authelia_for_forgejo_client_id}}",
"client_secret": "{{var_authelia_for_forgejo_client_secret}}",
"client_name": "Gitea",
"public": false,
"authorization_policy": "one_factor",
"redirect_uris": [
"{{var_authelia_for_gitea_gitea_url_base}}/user/oauth2/authelia/callback"
"{{var_authelia_for_forgejo_forgejo_url_base}}/user/oauth2/authelia/callback"
],
"scopes": [
"openid",

View file

@ -1,5 +1,5 @@
{
"var_gitea_and_nginx_domain": "gitea.example.org",
"var_gitea_and_nginx_port": 2378,
"var_gitea_and_nginx_tls_mode": "enable"
"var_forgejo_and_nginx_domain": "forgejo.example.org",
"var_forgejo_and_nginx_port": 2378,
"var_forgejo_and_nginx_tls_mode": "enable"
}

View file

@ -1,3 +1,3 @@
## Verweise
- [Gitea-Dokumentation](https://docs.gitea.com/next/administration/reverse-proxies#nginx)
- [Gitea-Dokumentation](https://docs.forgejo.com/next/administration/reverse-proxies#nginx)

View file

@ -12,7 +12,7 @@
"become": true,
"ansible.builtin.template": {
"src": "conf.j2",
"dest": "/etc/nginx/sites-available/{{var_gitea_and_nginx_domain}}"
"dest": "/etc/nginx/sites-available/{{var_forgejo_and_nginx_domain}}"
}
},
{
@ -20,8 +20,8 @@
"become": true,
"ansible.builtin.file": {
"state": "link",
"src": "/etc/nginx/sites-available/{{var_gitea_and_nginx_domain}}",
"dest": "/etc/nginx/sites-enabled/{{var_gitea_and_nginx_domain}}"
"src": "/etc/nginx/sites-available/{{var_forgejo_and_nginx_domain}}",
"dest": "/etc/nginx/sites-enabled/{{var_forgejo_and_nginx_domain}}"
}
},
{

View file

@ -1,6 +1,6 @@
{% macro gitea_common() %}
{% macro forgejo_common() %}
location / {
proxy_pass http://localhost:{{var_gitea_and_nginx_port | string}};
proxy_pass http://localhost:{{var_forgejo_and_nginx_port | string}};
client_max_body_size 20M;
}
{% endmacro %}
@ -9,26 +9,26 @@ server {
listen 80;
listen [::]:80;
server_name {{var_gitea_and_nginx_domain}};
server_name {{var_forgejo_and_nginx_domain}};
{% if var_gitea_and_nginx_tls_mode == 'force' %}
{% if var_forgejo_and_nginx_tls_mode == 'force' %}
return 301 https://$http_host$request_uri;
{% else %}
{{ gitea_common() }}
{{ forgejo_common() }}
{% endif %}
}
{% if var_gitea_and_nginx_tls_mode != 'disable' %}
{% if var_forgejo_and_nginx_tls_mode != 'disable' %}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name {{var_gitea_and_nginx_domain}};
server_name {{var_forgejo_and_nginx_domain}};
ssl_certificate_key /etc/ssl/private/{{var_gitea_and_nginx_domain}}.pem;
ssl_certificate /etc/ssl/fullchains/{{var_gitea_and_nginx_domain}}.pem;
ssl_certificate_key /etc/ssl/private/{{var_forgejo_and_nginx_domain}}.pem;
ssl_certificate /etc/ssl/fullchains/{{var_forgejo_and_nginx_domain}}.pem;
include /etc/nginx/ssl-hardening.conf;
{{ gitea_common() }}
{{ forgejo_common() }}
}
{% endif %}

View file

@ -1,29 +1,29 @@
{
"var_gitea_user": "gitea",
"var_gitea_directory": "/opt/gitea",
"var_gitea_version": "1.22.1",
"var_gitea_platform": "linux-amd64",
"var_gitea_secret_key": "REPLACE_ME",
"var_gitea_internal_token": "REPLACE_ME",
"var_gitea_domain": "gitea.example.org",
"var_gitea_listen_address": "0.0.0.0",
"var_gitea_listen_port": 2378,
"var_gitea_database_kind": "sqlite",
"var_gitea_database_data_sqlite_path": "/var/gitea/data.sqlite",
"var_gitea_database_data_postgresql_host": "postgresql.example.org",
"var_gitea_database_data_postgresql_port": 5432,
"var_gitea_database_data_postgresql_username": "gitea_user",
"var_gitea_database_data_postgresql_password": "REPLACE_ME",
"var_gitea_database_data_postgresql_scheme": "gitea",
"var_gitea_authentication_kind": "internal",
"var_gitea_authentication_data_authelia_url_base": "https://authelia.example.org",
"var_gitea_authentication_data_authelia_client_id": "gitea",
"var_gitea_authentication_data_authelia_client_secret": "REPLACE_ME",
"var_gitea_smtp_host": "smtp.example.org",
"var_gitea_smtp_port": 465,
"var_gitea_smtp_username": "REPLACE_ME",
"var_gitea_smtp_password": "REPLACE_ME",
"var_gitea_email_sending_enabled": false,
"var_gitea_email_sending_sender": "gitea@example.org",
"var_gitea_email_sending_html": false
"var_forgejo_user": "forgejo",
"var_forgejo_directory": "/opt/forgejo",
"var_forgejo_version": "1.22.1",
"var_forgejo_platform": "linux-amd64",
"var_forgejo_secret_key": "REPLACE_ME",
"var_forgejo_internal_token": "REPLACE_ME",
"var_forgejo_domain": "forgejo.example.org",
"var_forgejo_listen_address": "0.0.0.0",
"var_forgejo_listen_port": 2378,
"var_forgejo_database_kind": "sqlite",
"var_forgejo_database_data_sqlite_path": "/var/forgejo/data.sqlite",
"var_forgejo_database_data_postgresql_host": "postgresql.example.org",
"var_forgejo_database_data_postgresql_port": 5432,
"var_forgejo_database_data_postgresql_username": "forgejo_user",
"var_forgejo_database_data_postgresql_password": "REPLACE_ME",
"var_forgejo_database_data_postgresql_scheme": "forgejo",
"var_forgejo_authentication_kind": "internal",
"var_forgejo_authentication_data_authelia_url_base": "https://authelia.example.org",
"var_forgejo_authentication_data_authelia_client_id": "forgejo",
"var_forgejo_authentication_data_authelia_client_secret": "REPLACE_ME",
"var_forgejo_smtp_host": "smtp.example.org",
"var_forgejo_smtp_port": 465,
"var_forgejo_smtp_username": "REPLACE_ME",
"var_forgejo_smtp_password": "REPLACE_ME",
"var_forgejo_email_sending_enabled": false,
"var_forgejo_email_sending_sender": "forgejo@example.org",
"var_forgejo_email_sending_html": false
}

View file

@ -1,10 +1,10 @@
## Beschreibung
Zur Einrichtung der DevOps-Platform [Gitea](https://about.gitea.com/)
Zur Einrichtung der DevOps-Platform [Gitea](https://about.forgejo.com/)
## Verweise
- [Gitea Homepage | self hosting](https://about.gitea.com/products/gitea/)
- [Gitea Documentation | Installation from binary](https://docs.gitea.com/installation/install-from-binary)
- [Gitea Documentation | Config Cheat Sheet](https://docs.gitea.com/administration/config-cheat-sheet)
- [Gitea Homepage | self hosting](https://about.forgejo.com/products/forgejo/)
- [Gitea Documentation | Installation from binary](https://docs.forgejo.com/installation/install-from-binary)
- [Gitea Documentation | Config Cheat Sheet](https://docs.forgejo.com/administration/config-cheat-sheet)

View file

@ -13,16 +13,16 @@
"name": "user",
"become": true,
"ansible.builtin.user": {
"name": "{{var_gitea_user}}",
"name": "{{var_forgejo_user}}",
"create_home": true,
"home": "{{var_gitea_directory}}"
"home": "{{var_forgejo_directory}}"
}
},
{
"name": "directories | database",
"become": true,
"loop": [
"{{var_gitea_database_data_sqlite_path | dirname}}"
"{{var_forgejo_database_data_sqlite_path | dirname}}"
],
"ansible.builtin.file": {
"path": "{{item}}",
@ -32,9 +32,9 @@
{
"name": "directories | internal",
"become": true,
"become_user": "{{var_gitea_user}}",
"become_user": "{{var_forgejo_user}}",
"loop": [
"{{var_gitea_directory}}/custom/conf"
"{{var_forgejo_directory}}/custom/conf"
],
"ansible.builtin.file": {
"path": "{{item}}",
@ -44,39 +44,39 @@
{
"name": "download",
"become": true,
"become_user": "{{var_gitea_user}}",
"become_user": "{{var_forgejo_user}}",
"ansible.builtin.get_url": {
"url": "https://dl.gitea.com/gitea/{{var_gitea_version}}/gitea-{{var_gitea_version}}-{{var_gitea_platform}}",
"dest": "{{var_gitea_directory}}/gitea",
"url": "https://dl.forgejo.com/forgejo/{{var_forgejo_version}}/forgejo-{{var_forgejo_version}}-{{var_forgejo_platform}}",
"dest": "{{var_forgejo_directory}}/forgejo",
"mode": "u+rx"
}
},
{
"name": "config | base",
"become": true,
"become_user": "{{var_gitea_user}}",
"become_user": "{{var_forgejo_user}}",
"ansible.builtin.template": {
"src": "config.ini.j2",
"dest": "{{var_gitea_directory}}/custom/conf/app.ini"
"dest": "{{var_forgejo_directory}}/custom/conf/app.ini"
}
},
{
"name": "config | database",
"become": true,
"become_user": "{{var_gitea_user}}",
"become_user": "{{var_forgejo_user}}",
"ansible.builtin.command": {
"chdir": "{{var_gitea_directory}}",
"cmd": "./gitea migrate"
"chdir": "{{var_forgejo_directory}}",
"cmd": "./forgejo migrate"
}
},
{
"name": "config | authelia",
"when": "var_gitea_authentication_kind == 'authelia'",
"when": "var_forgejo_authentication_kind == 'authelia'",
"become": true,
"become_user": "{{var_gitea_user}}",
"become_user": "{{var_forgejo_user}}",
"ansible.builtin.command": {
"chdir": "{{var_gitea_directory}}",
"cmd": "./gitea admin auth add-oauth --provider='openidConnect' --name='authelia' --key={{var_gitea_authentication_data_authelia_client_id}} --secret={{var_gitea_authentication_data_authelia_client_secret}} --auto-discover-url='{{var_gitea_authentication_data_authelia_url_base}}/.well-known/openid-configuration' --scopes='openid email profile'"
"chdir": "{{var_forgejo_directory}}",
"cmd": "./forgejo admin auth add-oauth --provider='openidConnect' --name='authelia' --key={{var_forgejo_authentication_data_authelia_client_id}} --secret={{var_forgejo_authentication_data_authelia_client_secret}} --auto-discover-url='{{var_forgejo_authentication_data_authelia_url_base}}/.well-known/openid-configuration' --scopes='openid email profile'"
}
},
{
@ -84,7 +84,7 @@
"become": true,
"ansible.builtin.template": {
"src": "systemd-unit.j2",
"dest": "/etc/systemd/system/gitea.service"
"dest": "/etc/systemd/system/forgejo.service"
}
},
{
@ -93,7 +93,7 @@
"ansible.builtin.systemd_service": {
"enabled": true,
"state": "restarted",
"name": "gitea"
"name": "forgejo"
}
}
]

View file

@ -1,31 +1,31 @@
APP_NAME = Gitea: Git with a cup of tea
RUN_USER = {{var_gitea_user}}
RUN_USER = {{var_forgejo_user}}
RUN_MODE = prod
[server]
DOMAIN = {{var_gitea_domain}}
ROOT_URL = https://{{var_gitea_domain}}
;HTTP_ADDR = {{var_gitea_listen_address}}
HTTP_PORT = {{var_gitea_listen_port | string}}
DOMAIN = {{var_forgejo_domain}}
ROOT_URL = https://{{var_forgejo_domain}}
;HTTP_ADDR = {{var_forgejo_listen_address}}
HTTP_PORT = {{var_forgejo_listen_port | string}}
;LANDING_PAGE = home
[database]
{% if var_gitea_database_kind == 'sqlite' %}
{% if var_forgejo_database_kind == 'sqlite' %}
DB_TYPE = sqlite3
PATH = {{var_gitea_database_data_sqlite_path}}
PATH = {{var_forgejo_database_data_sqlite_path}}
{% endif %}
{% if var_gitea_database_kind == 'postgresql' %}
{% if var_forgejo_database_kind == 'postgresql' %}
DB_TYPE = postgres
HOST = {{var_gitea_database_data_postgresql_host}}:{{var_gitea_database_data_postgresql_port | string}}
USER = {{var_gitea_database_data_postgresql_username}}
PASSWD = {{var_gitea_database_data_postgresql_password}}
NAME = {{var_gitea_database_data_postgresql_scheme}}
HOST = {{var_forgejo_database_data_postgresql_host}}:{{var_forgejo_database_data_postgresql_port | string}}
USER = {{var_forgejo_database_data_postgresql_username}}
PASSWD = {{var_forgejo_database_data_postgresql_password}}
NAME = {{var_forgejo_database_data_postgresql_scheme}}
{% endif %}
[security]
INSTALL_LOCK = true
SECRET_KEY = {{var_gitea_secret_key}}
INTERNAL_TOKEN = {{var_gitea_internal_token}}
SECRET_KEY = {{var_forgejo_secret_key}}
INTERNAL_TOKEN = {{var_forgejo_internal_token}}
DISABLE_GIT_HOOKS = true
[oauth2]
@ -36,12 +36,12 @@ MODE = console
LEVEL = Info
[git]
HOME_PATH = {{var_gitea_directory}}
HOME_PATH = {{var_forgejo_directory}}
[service]
REGISTER_EMAIL_CONFIRM = false
{% if var_gitea_authentication_kind == 'internal' %}
{% if var_forgejo_authentication_kind == 'internal' %}
DISABLE_REGISTRATION = false
ALLOW_ONLY_INTERNAL_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
@ -76,7 +76,7 @@ ENABLE_USER_HEATMAP = false
ENABLE_TIMETRACKING = false
DEFAULT_ENABLE_TIMETRACKING = false
{% if var_gitea_authentication_kind == 'internal' %}
{% if var_forgejo_authentication_kind == 'internal' %}
SHOW_REGISTRATION_BUTTON = true
{% else %}
SHOW_REGISTRATION_BUTTON = false
@ -85,7 +85,7 @@ SHOW_REGISTRATION_BUTTON = false
AUTO_WATCH_NEW_REPOS = false
AUTO_WATCH_ON_CHANGES = false
{% if var_gitea_authentication_kind == 'internal' %}
{% if var_forgejo_authentication_kind == 'internal' %}
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false
@ -93,7 +93,7 @@ ENABLE_OPENID_SIGNUP = false
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = true
WHITELISTED_URIS = {{var_gitea_authentication_data_authelia_url_base}}
WHITELISTED_URIS = {{var_forgejo_authentication_data_authelia_url_base}}
[oauth2_client]
REGISTER_EMAIL_CONFIRM = false
@ -103,14 +103,14 @@ USERNAME = nickname
{% endif %}
[mailer]
{% if var_gitea_email_sending_enabled %}
{% if var_forgejo_email_sending_enabled %}
ENABLED = true
SMTP_ADDR = {{var_gitea_smtp_host}}
SMTP_PORT = {{var_gitea_smtp_port | string}}
FROM = {{var_gitea_email_sending_sender}}
USER = {{var_gitea_smtp_username}}
PASSWD = {{var_gitea_smtp_password}}
{% if var_gitea_email_sending_html %}
SMTP_ADDR = {{var_forgejo_smtp_host}}
SMTP_PORT = {{var_forgejo_smtp_port | string}}
FROM = {{var_forgejo_email_sending_sender}}
USER = {{var_forgejo_smtp_username}}
PASSWD = {{var_forgejo_smtp_password}}
{% if var_forgejo_email_sending_html %}
SEND_AS_PLAIN_TEXT = false
{% else %}
SEND_AS_PLAIN_TEXT = true

View file

@ -1,7 +1,7 @@
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
{% if var_gitea_database_kind == 'postgresql' %}
{% if var_forgejo_database_kind == 'postgresql' %}
Wants=postgresql.service
After=postgresql.service
{% endif %}
@ -9,12 +9,12 @@ After=postgresql.service
[Service]
RestartSec=2s
Type=simple
User={{var_gitea_user}}
Group={{var_gitea_user}}
WorkingDirectory={{var_gitea_directory}}
ExecStart={{var_gitea_directory}}/gitea web --config {{var_gitea_directory}}/custom/conf/app.ini
User={{var_forgejo_user}}
Group={{var_forgejo_user}}
WorkingDirectory={{var_forgejo_directory}}
ExecStart={{var_forgejo_directory}}/forgejo web --config {{var_forgejo_directory}}/custom/conf/app.ini
Restart=always
# Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
# Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/forgejo
# Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin
[Install]

View file

@ -1,5 +1,5 @@
{
"var_postgresql_for_gitea_username": "gitea_user",
"var_postgresql_for_gitea_password": "REPLACE_ME",
"var_postgresql_for_gitea_schema": "gitea"
"var_postgresql_for_forgejo_username": "forgejo_user",
"var_postgresql_for_forgejo_password": "REPLACE_ME",
"var_postgresql_for_forgejo_schema": "forgejo"
}

View file

@ -16,8 +16,8 @@
"become_user": "postgres",
"community.postgresql.postgresql_user": {
"state": "present",
"name": "{{var_postgresql_for_gitea_username}}",
"password": "{{var_postgresql_for_gitea_password}}"
"name": "{{var_postgresql_for_forgejo_username}}",
"password": "{{var_postgresql_for_forgejo_password}}"
},
"environment": {
"PGOPTIONS": "-c password_encryption=scram-sha-256"
@ -29,8 +29,8 @@
"become_user": "postgres",
"community.postgresql.postgresql_db": {
"state": "present",
"name": "{{var_postgresql_for_gitea_schema}}",
"owner": "{{var_postgresql_for_gitea_username}}"
"name": "{{var_postgresql_for_forgejo_schema}}",
"owner": "{{var_postgresql_for_forgejo_username}}"
}
},
{
@ -39,9 +39,9 @@
"become_user": "postgres",
"community.postgresql.postgresql_privs": {
"state": "present",
"db": "{{var_postgresql_for_gitea_schema}}",
"db": "{{var_postgresql_for_forgejo_schema}}",
"objs": "ALL_IN_SCHEMA",
"roles": "{{var_postgresql_for_gitea_username}}",
"roles": "{{var_postgresql_for_forgejo_username}}",
"privs": "ALL",
"grant_option": true
}