1.3.0 Release gitea

This commit is contained in:
2026-03-15 06:17:01 +09:00
parent 90277b2d4e
commit 8311fcf53e
12 changed files with 294 additions and 2 deletions

View File

@@ -74,3 +74,4 @@ version:
authelia: "4.39.15"
# App
vaultwarden: "1.35.4"
gitea: "1.25.5"

View File

@@ -169,6 +169,14 @@
tags: ["site", "vaultwarden"]
tags: ["site", "vaultwarden"]
- name: Set gitea
ansible.builtin.include_role:
name: "app"
tasks_from: "services/set_gitea"
apply:
tags: ["site", "gitea"]
tags: ["site", "gitea"]
- name: Flush handlers right now
ansible.builtin.meta: "flush_handlers"

View File

@@ -9,3 +9,14 @@
changed_when: false
listen: "notification_restart_vaultwarden"
ignore_errors: true # noqa: ignore-errors
- name: Restart gitea
ansible.builtin.systemd:
name: "gitea.service"
state: "restarted"
enabled: true
scope: "user"
daemon_reload: true
changed_when: false
listen: "notification_restart_gitea"
ignore_errors: true # noqa: ignore-errors

View File

@@ -0,0 +1,54 @@
---
- name: Set gitea container subuid
ansible.builtin.set_fact:
gitea_subuid: "100999"
- name: Create gitea directory
ansible.builtin.file:
path: "{{ node['home_path'] }}/{{ item }}"
state: "directory"
owner: "{{ gitea_subuid }}"
group: "svadmins"
mode: "0770"
loop:
- "data/containers/gitea"
- "containers/gitea"
- "containers/gitea/ssl"
become: true
- name: Deploy root certificate
ansible.builtin.copy:
content: |
{{ hostvars['console']['ca']['root']['crt'] }}
dest: "{{ node['home_path'] }}/containers/gitea/ssl/ilnmors_root_ca.crt"
owner: "{{ gitea_subuid }}"
group: "svadmins"
mode: "0440"
become: true
notify: "notification_restart_gitea"
no_log: true
- name: Register secret value to podman secret
containers.podman.podman_secret:
name: "GITEA__database__PASSWD"
data: "{{ hostvars['console']['postgresql']['password']['gitea'] }}"
state: "present"
force: true
no_log: true
- name: Deploy container file
ansible.builtin.template:
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/gitea/gitea.container.j2"
dest: "{{ node['home_path'] }}/.config/containers/systemd/gitea.container"
owner: "{{ ansible_user }}"
group: "svadmins"
mode: "0644"
notify: "notification_restart_gitea"
- name: Enable gitea.service
ansible.builtin.systemd:
name: "gitea.service"
state: "started"
enabled: true
daemon_reload: true
scope: "user"

View File

@@ -11,6 +11,7 @@
- "authelia"
- "grafana"
- "vaultwarden"
- "gitea"
- name: Create postgresql directory
ansible.builtin.file:

View File

@@ -114,6 +114,7 @@ postgresql:
grafana: ENC[AES256_GCM,data:P9okJ7bcsqmeGstkSwbDq/RgnG+lFrgAOvcj8A5lOTpmHaSlXGiKG+ybXa0=,iv:Di1ghnxIbAb/u7uo/mJCC3QYVjdweTHaQDZmXTx8OG4=,tag:DT3a1zgU9sTr0BXpyoZ/SQ==,type:str]
authelia: ENC[AES256_GCM,data:OqyloAADO6KKEaBjGLsJc9GTe77wn6IvA1VCD2dfCWxx+zgzUYh87fK1XX8=,iv:QIOHNTdNnzcY/f3Co8dPdNHykhBnYRhm43nt35hbALM=,tag:DLQq58GrZd+Ul7MSn6s9uQ==,type:str]
vaultwarden: ENC[AES256_GCM,data:BPj5eFo54DTZ82n3yTIqEbm7kb/jWT0n2kZY//oV5q48eRch3C2RBuxn/Ko=,iv:DGC4ipHMyVs25gc4sNMt8LN1RsHjiR/b303vgiFoxMY=,tag:k1eb4DoRPLKvvMstSI1faQ==,type:str]
gitea: ENC[AES256_GCM,data:l+pBCzyQa3000SE9z1R4htD0V0ONsBtKy92dfgsVYsZ3XlEyVJDIBOsugwM=,iv:5t/oHW1vFAmV/s2Ze/cV9Vuqo96Qu6QvZeRbio7VX2s=,tag:4zeQaXiXIzBpy+tXsxmN7Q==,type:str]
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
#
#
@@ -183,6 +184,17 @@ vaultwarden:
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
#
#
#ENC[AES256_GCM,data:HAN9BBEl1CW11LAf3x8=,iv:hwqCErtmPqGJ+y86D9MoxJwixvbcJONlyT900Y5DOug=,tag:kCxsG353ltbOCKLe85adCg==,type:comment]
gitea:
il:
password: ENC[AES256_GCM,data:Bs5/t5mNbSv5+ek9gNHZp5qqxitM4Kq0Xgh2JV6LiFw9lZJSOVT4JPLRP5M=,iv:z50+naWOTVL8lEgBgm51j6hLjS8ve2UcRRKukvtykM0=,tag:TF9rPxjoLe/vAyvl23PiCg==,type:str]
token: ENC[AES256_GCM,data:CiYEXEKLLRDp++iga5YmhyPB2bSvqhhDgSOhmiulp9n9SsBVQ3s5MQ==,iv:+oetgEH/IORz74Xoz5zgDjD3BLyledZTqlYlCWaDrRk=,tag:S9O09YEMuSexuNW3ojEw5Q==,type:str]
oidc:
secret: ENC[AES256_GCM,data:qjQosi83oaK47wX4VtDktDFlIU3FQgmDpwyiSgJNPDq2Dtc/QEKzdv5/ZpQ=,iv:aUJx5a6Wj7lhaD19aPiZWIE/MWKUgH0muxtTSkwfg8M=,tag:DttjXee7ntxRAbqbFq6qeQ==,type:str]
hash: ENC[AES256_GCM,data:iVls8UzdP6JTfRosET6nsk3RcEtFQ8ak6GtPuBjcqAv3lyA9oSLwvvC8MvGaT1aHCB+5y/lspuloHEaAcVGNuzGCIVLg9Adut4a7LYDTHNOZnJIKLj8ldL1ytD5XVdbeBhZGCqoTs088oO0HVCQiDzpJL5NdmM3Ru6egyYBCLLUOlPA=,iv:er63GEC+kxNDscvspvvLiq17VSg0GeZ2w3jmGojF9PM=,tag:F1pDpaQrVdomIlZ8psVpAw==,type:str]
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
#
#
#ENC[AES256_GCM,data:T4Wtn49AAxPd2QUFTR+q,iv:bH5goGWBDqumAat9dUv2OwfCUJUpuVqncTMqMBZUXhI=,tag:G+W6hHA+yftQ+4RJpXrxHg==,type:comment]
switch:
password: ENC[AES256_GCM,data:qu0f9L7A0eFq/UCpaRs=,iv:W8LLOp3MSfd/+EfNEZNf91K8GgI5eUfVPoWTRES2C0Y=,tag:Q5FlAOfwqwJwPvd7k6i+0g==,type:str]
@@ -212,7 +224,7 @@ sops:
UmliaFNxVTBqRkI1QWJpWGpTRWxETW8KEY/8AfU73UOzCGhny1cNnd5dCNv7bHXt
k+uyWPPi+enFkVaceSwMFrA66uaWWrwAj11sXEB7yzvGFPrnAGezjQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2026-03-14T19:42:34Z"
mac: ENC[AES256_GCM,data:xnsUauduZtPvf7MHkCWkzxpD8tCKDZZ97jskvi8jOeQdRM+L9U0bs3PTfrSeXjRvt1FCEDLyLxh6+NUBmGdI24/9mPU8wVN2sLVLKQ4HkXneCiKErRLoVKdliJGD9YxpkSNuYkwNyiM442akJUG0sVJOGcOGIrxn2msqCZlwSuk=,iv:AUqsg6B6CFVKcnBX+g126Xva7+xeNpTQ3FBKVVWoGFw=,tag:YMMZXfXON0MAahtjKWWWzw==,type:str]
lastmodified: "2026-03-14T21:11:56Z"
mac: ENC[AES256_GCM,data:cTm/Vrukt1cnq5xWmfF7J3xhDrVH94ampOK1IqZgsBICuJgDm6VYbntElCcnrmPE4BrIAFr8SyDQa28QgLf+e2UBn36yVUNZTor1kx24WkMsjj4MIRJRlYSQoFAg1iJSGTshqiwgQQMfj1nOCctLXdNAyQFWHt+E+9zqeXFB/l8=,iv:/dDIeqEW8/T5V8glumE3cTTy9e3bFAvg3GaMHAYkFi0=,tag:7eUKYIkju8wniz+/xmGfgg==,type:str]
unencrypted_suffix: _unencrypted
version: 3.12.1

View File

@@ -0,0 +1,51 @@
[Quadlet]
DefaultDependencies=false
[Unit]
Description=Gitea
After=network-online.target
Wants=network-online.target
[Container]
Image=docker.io/gitea/gitea:{{ version['containers']['gitea'] }}
ContainerName=gitea
HostName=gitea
PublishPort=3000:3000/tcp
Volume=%h/data/containers/gitea:/data:rw
Volume=%h/containers/gitea/ssl:/etc/ssl/gitea:ro
# General
Environment="TZ=Asia/Seoul"
Environment="GITEA__server__DISABLE_SSH=true"
# Database
Environment="GITEA__database__DB_TYPE=postgres"
Environment="GITEA__database__HOST={{ infra_uri['postgresql']['domain'] }}:{{ infra_uri['postgresql']['ports']['tcp'] }}"
Environment="GITEA__database__NAME=gitea_db"
Environment="GITEA__database__USER=gitea"
Secret=GITEA__database__PASSWD,type=env
Environment="GITEA__database__SSL_MODE=verify-full"
Environment="PGSSLROOTCERT=/etc/ssl/gitea/ilnmors_root_ca.crt"
# OAuth2 client
Environment="GITEA__oauth2_client__ACCOUNT_LINKING=auto"
# OIDC configuration
Environment="GITEA__openid__ENABLE_OPENID_SIGNIN=false"
Environment="GITEA__openid__ENABLE_OPENID_SIGNUP=true"
Environment="GITEA__openid__WHITELISTED_URIS=authelia.ilnmors.com"
# automatic create user via authelia
Environment="GITEA__service__DISABLE_REGISTRATION=false"
Environment="GITEA__service__ALLOW_ONLY_EXTERNAL_REGISTRATION=true"
Environment="GITEA__service__SHOW_REGISTRATION_BUTTON=false"
[Service]
ExecStartPre=/usr/bin/nc -zv {{ infra_uri['postgresql']['domain'] }} {{ infra_uri['postgresql']['ports']['tcp'] }}
Restart=always
RestartSec=10s
TimeoutStopSec=120
[Install]
WantedBy=default.target

View File

@@ -131,3 +131,24 @@ identity_providers:
userinfo_signed_response_alg: 'none'
# [ client_secret_post | client_secret_basic ]
token_endpoint_auth_method: 'client_secret_post'
# https://www.authelia.com/integration/openid-connect/clients/gitea/
- client_id: 'gitea'
client_name: 'gitea'
client_secret: '{{ hostvars['console']['gitea']['oidc']['hash'] }}'
public: false
authorization_policy: 'one_factor'
require_pkce: false
pkce_challenge_method: ''
redirect_uris:
- 'https://gitea.ilnmors.com/user/oauth2/authelia/callback'
scopes:
- 'openid'
- 'email'
- 'profile'
response_types:
- 'code'
grant_types:
- 'authorization_code'
access_token_signed_response_alg: 'none'
userinfo_signed_response_alg: 'none'
token_endpoint_auth_method: 'client_secret_basic'

View File

@@ -34,3 +34,9 @@ vault.app.ilnmors.internal {
header_up Host {http.request.header.X-Forwarded-Host}
}
}
gitea.app.ilnmors.internal {
import private_tls
reverse_proxy host.containers.internal:3000 {
header_up Host {http.request.header.X-Forwarded-Host}
}
}

View File

@@ -72,6 +72,15 @@ vault.ilnmors.com {
}
}
}
gitea.ilnmors.com {
import crowdsec_log
route {
crowdsec
reverse_proxy https://gitea.app.ilnmors.internal {
header_up Host {http.reverse_proxy.upstream.host}
}
}
}
# Internal domain
auth.ilnmors.internal {

View File

@@ -69,3 +69,27 @@ git tag -a 0.0.1-caddy-app -m "caddy-app: Start caddy-app branch"
git switch main
git merge caddy-app
```
## Connect local git and remote git
- Set this after gitea is implemented
```bash
# Add git remote repository
git config --global credential.helper store
git remote add origin https://gitea.ilnmors.com/il/ilnmors-homelab.git
# For first time to make connection between local and remote git
git push -u origin main
# Username for 'https://gitea.ilnmors.com': il
# Password for 'https://il@gitea.ilnmors.com': gitea.il.token
git push --tags
# After first connection, -u origin main option is not needed
git add $PATH
git commit -m "comment"
git tag -a $VERSION -m "comment"
git push && git push --tags
# -f and --force-with-lease can be used in commit and tags
# -f option and --force-with-lease
# -f: just overwrite forcefully without any condition. it is dangerous, because it doesn't care the changes (commit) from other local git
# --force-with-lease: overwrite forcefully only when there's no changes (commit) from other local git
```

View File

@@ -0,0 +1,94 @@
# gitea
## Prerequisite
### Create database
- Create the password with `openssl rand -base64 32`
- Save this value in secrets.yaml in `postgres.password.gitea`
- Access infra server to create gitea_db with `podman exec -it postgresql psql -U postgres`
```SQL
CREATE USER gitea WITH PASSWORD 'gitea.password.vaultwarden';
CREATE DATABASE gitea_db;
ALTER DATABASE gitea_db OWNER TO gitea;
```
### Create oidc secret and hash
- Create the secret with `openssl rand -base64 32`
- access to auth vm
- `podman exec -it authelia sh`
- `authelia crypto hash generate pbkdf2 --password 'gitea.oidc.secret'`
- Save this value in secrets.yaml in `gitea.oidc.secret` and `gitea.oidc.hash`
### Create admin password
- Create the secret with `openssl rand -base64 32`
- Save this value in secrets.yaml in `gitea.admin.password`
-
### Add postgresql dump backup list
- [set_postgresql.yaml](../../../ansible/roles/infra/tasks/services/set_postgresql.yaml)
```yaml
- name: Set connected services list
ansible.builtin.set_fact:
# telegraf has no database
connected_services:
- ...
- "gitea"
```
## Configuration
### Site installation
- **!CAUTION!** This is needed Only when first installing. This process isn't needed when the data is restored on `~/data/containers/gitea`
- https://gitea.ilnmors.com
- General setting
- Site Title: Gitea: ilnmors
- Administrator Account Setting
- Administrator Username: il
- Email Address il@ilnmors.internal
- Password & confirm password: gitea.il.password
- Install Gitea
### Oauth configuration
- Site Administration
- Identity & Access: Authentication Sources: Add Authentication Source
- Configure the following options:
- Authentication Type: OAuth2
- Authentication Name: authelia
- OAuth2 Provider: OpenID Connect
- Client ID (Key): gitea
- Client Secret: gitea.oidc.secret
- OpenID Connect Auto Discovery URL: https://authelia.ilnmors.com/.well-known/openid-configuration
### Link Account via OAuth2
- Login with autheila
- Register New Account
- Link to Existing Account
- Link the account of administrational account which set at the inital install page
- id and password
### Set repository access token
- Settings: Applications: Generate New Token
- Token name: ilnmors-homelab
- Repository and Organization Access: All
- repository - Read and Write
- Generate Token
- Copy token value and save this in `secrets.yaml`
## Connect with loacl git repository
### Create remote git repository
- Repository: `+`
- Name: ilnmors-homelab
- etc: default vaules
- Following [07-git.md](../../runbook/07-git.md)