[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_forgejo_forgejo_url_base": "https://forgejo.example.org",
"var_authelia_for_gitea_client_id": "gitea", "var_authelia_for_forgejo_client_id": "forgejo",
"var_authelia_for_gitea_client_secret": "REPLACE_ME" "var_authelia_for_forgejo_client_secret": "REPLACE_ME"
} }

View file

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

View file

@ -4,7 +4,7 @@
"become": true, "become": true,
"ansible.builtin.template": { "ansible.builtin.template": {
"src": "authelia-client-conf.json.j2", "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_id": "{{var_authelia_for_forgejo_client_id}}",
"client_secret": "{{var_authelia_for_gitea_client_secret}}", "client_secret": "{{var_authelia_for_forgejo_client_secret}}",
"client_name": "Gitea", "client_name": "Gitea",
"public": false, "public": false,
"authorization_policy": "one_factor", "authorization_policy": "one_factor",
"redirect_uris": [ "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": [ "scopes": [
"openid", "openid",

View file

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

View file

@ -1,3 +1,3 @@
## Verweise ## 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, "become": true,
"ansible.builtin.template": { "ansible.builtin.template": {
"src": "conf.j2", "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, "become": true,
"ansible.builtin.file": { "ansible.builtin.file": {
"state": "link", "state": "link",
"src": "/etc/nginx/sites-available/{{var_gitea_and_nginx_domain}}", "src": "/etc/nginx/sites-available/{{var_forgejo_and_nginx_domain}}",
"dest": "/etc/nginx/sites-enabled/{{var_gitea_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 / { 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; client_max_body_size 20M;
} }
{% endmacro %} {% endmacro %}
@ -9,26 +9,26 @@ server {
listen 80; listen 80;
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; return 301 https://$http_host$request_uri;
{% else %} {% else %}
{{ gitea_common() }} {{ forgejo_common() }}
{% endif %} {% endif %}
} }
{% if var_gitea_and_nginx_tls_mode != 'disable' %} {% if var_forgejo_and_nginx_tls_mode != 'disable' %}
server { server {
listen 443 ssl; listen 443 ssl;
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_key /etc/ssl/private/{{var_forgejo_and_nginx_domain}}.pem;
ssl_certificate /etc/ssl/fullchains/{{var_gitea_and_nginx_domain}}.pem; ssl_certificate /etc/ssl/fullchains/{{var_forgejo_and_nginx_domain}}.pem;
include /etc/nginx/ssl-hardening.conf; include /etc/nginx/ssl-hardening.conf;
{{ gitea_common() }} {{ forgejo_common() }}
} }
{% endif %} {% endif %}

View file

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

View file

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

View file

@ -13,16 +13,16 @@
"name": "user", "name": "user",
"become": true, "become": true,
"ansible.builtin.user": { "ansible.builtin.user": {
"name": "{{var_gitea_user}}", "name": "{{var_forgejo_user}}",
"create_home": true, "create_home": true,
"home": "{{var_gitea_directory}}" "home": "{{var_forgejo_directory}}"
} }
}, },
{ {
"name": "directories | database", "name": "directories | database",
"become": true, "become": true,
"loop": [ "loop": [
"{{var_gitea_database_data_sqlite_path | dirname}}" "{{var_forgejo_database_data_sqlite_path | dirname}}"
], ],
"ansible.builtin.file": { "ansible.builtin.file": {
"path": "{{item}}", "path": "{{item}}",
@ -32,9 +32,9 @@
{ {
"name": "directories | internal", "name": "directories | internal",
"become": true, "become": true,
"become_user": "{{var_gitea_user}}", "become_user": "{{var_forgejo_user}}",
"loop": [ "loop": [
"{{var_gitea_directory}}/custom/conf" "{{var_forgejo_directory}}/custom/conf"
], ],
"ansible.builtin.file": { "ansible.builtin.file": {
"path": "{{item}}", "path": "{{item}}",
@ -44,39 +44,39 @@
{ {
"name": "download", "name": "download",
"become": true, "become": true,
"become_user": "{{var_gitea_user}}", "become_user": "{{var_forgejo_user}}",
"ansible.builtin.get_url": { "ansible.builtin.get_url": {
"url": "https://dl.gitea.com/gitea/{{var_gitea_version}}/gitea-{{var_gitea_version}}-{{var_gitea_platform}}", "url": "https://dl.forgejo.com/forgejo/{{var_forgejo_version}}/forgejo-{{var_forgejo_version}}-{{var_forgejo_platform}}",
"dest": "{{var_gitea_directory}}/gitea", "dest": "{{var_forgejo_directory}}/forgejo",
"mode": "u+rx" "mode": "u+rx"
} }
}, },
{ {
"name": "config | base", "name": "config | base",
"become": true, "become": true,
"become_user": "{{var_gitea_user}}", "become_user": "{{var_forgejo_user}}",
"ansible.builtin.template": { "ansible.builtin.template": {
"src": "config.ini.j2", "src": "config.ini.j2",
"dest": "{{var_gitea_directory}}/custom/conf/app.ini" "dest": "{{var_forgejo_directory}}/custom/conf/app.ini"
} }
}, },
{ {
"name": "config | database", "name": "config | database",
"become": true, "become": true,
"become_user": "{{var_gitea_user}}", "become_user": "{{var_forgejo_user}}",
"ansible.builtin.command": { "ansible.builtin.command": {
"chdir": "{{var_gitea_directory}}", "chdir": "{{var_forgejo_directory}}",
"cmd": "./gitea migrate" "cmd": "./forgejo migrate"
} }
}, },
{ {
"name": "config | authelia", "name": "config | authelia",
"when": "var_gitea_authentication_kind == 'authelia'", "when": "var_forgejo_authentication_kind == 'authelia'",
"become": true, "become": true,
"become_user": "{{var_gitea_user}}", "become_user": "{{var_forgejo_user}}",
"ansible.builtin.command": { "ansible.builtin.command": {
"chdir": "{{var_gitea_directory}}", "chdir": "{{var_forgejo_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'" "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, "become": true,
"ansible.builtin.template": { "ansible.builtin.template": {
"src": "systemd-unit.j2", "src": "systemd-unit.j2",
"dest": "/etc/systemd/system/gitea.service" "dest": "/etc/systemd/system/forgejo.service"
} }
}, },
{ {
@ -93,7 +93,7 @@
"ansible.builtin.systemd_service": { "ansible.builtin.systemd_service": {
"enabled": true, "enabled": true,
"state": "restarted", "state": "restarted",
"name": "gitea" "name": "forgejo"
} }
} }
] ]

View file

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

View file

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

View file

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

View file

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