untested: added ansible

This commit is contained in:
Kyattsukuro 2026-09-28 21:59:37 +02:00
parent 1c4a25aa5b
commit 02b27cf74d
7 changed files with 93 additions and 20 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# gitea

13
defaults/main.yml Normal file
View File

@ -0,0 +1,13 @@
path: /srv/{{ role_name }}
gitea_override: {}
gitea_defaults:
version: "stable"
url: ""
db_password: ""
data_path: ""
networkmount:
host: "217.100.0.2"
host_path: "/mnt/Main/nextcloudData"
args: "rw,noatime,tcp"
enable_ssh: false

9
handlers/main.yml Normal file
View File

@ -0,0 +1,9 @@
- name: restart container
community.docker.docker_compose_v2:
project_src: "{{ path }}"
project_name: "{{ role_name }}"
recreate: "always"
services: ["gitea"]
state: "restarted"
when: not _gitea_already_restarted

20
meta/main.yml Normal file
View File

@ -0,0 +1,20 @@
---
galaxy_info:
author: "Niklas Freese <niklas@urmel.de>"
description: gitea
company: "Urmel Services"
license: AGPL-3.0-or-later
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# dependencies:
# - role: base

39
tasks/main.yml Normal file
View File

@ -0,0 +1,39 @@
---
- name: "set local variables from overrides and defaults"
set_fact:
gitea: "{{ (gitea_defaults | combine(gitea_override, recursive=True)) if gitea_override else gitea_defaults }}"
- name: ensure that path exists
file:
path: "{{ path }}/config/gitea"
state: directory
- name: template compose
template:
src: compose.yml.j2
dest: "{{ path }}/compose.yml"
- name: Copy ssh config
copy:
src: files/ssh
dest: "{{ path }}/config/gitea/ssh"
- import_role:
name: storage_mount
vars:
storagebox_override:
host: "{{ gitea.networkmount.host }}"
host_path: "{{ gitea.networkmount.host_path }}"
args: "{{ gitea.networkmount.args }}"
dest_path: "{{ gitea.data_path }}"
when: gitea.networkmount.host | length > 1
- name: ensure containers are running
community.docker.docker_compose_v2:
project_src: "{{ path }}"
project_name: "{{ role_name }}"
state: "present"
pull: "always"
wait: true
services: [ 'gitea', 'db' ]
register: _compose_result

View File

@ -1,8 +1,6 @@
version: "3"
services:
server:
image: docker.gitea.com/gitea:1.23.7
gitea:
image: docker.gitea.com/gitea:{{ gitea.version }}
environment:
- USER_UID=1000
- USER_GID=1000
@ -10,42 +8,44 @@ services:
- GITEA__database__HOST=db:5432
- GITEA__database__NAME=gitea
- GITEA__database__USER=gitea
- GITEA__database__PASSWD=${POSTGRES_PASSWORD}
- GITEA__database__PASSWD={{ gitea.db_password }}
- SSH_INCLUDE_FILE=/etc/ssh/sshd_config.d/*.conf
restart: always
networks:
- internal
- proxy
volumes:
- gitea:/data
- {{ gitea.data_path }}:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
# https://github.com/go-gitea/gitea/issues/34179
- ${PROJECT_PATH-$PWD}/config/ssh_penalties.conf:/etc/ssh/sshd_config.d/penalties.conf
- ./config/gitea/ssh:/etc/ssh/sshd_config.d
depends_on:
- db
labels:
traefik.enable: true
traefik.http.routers.gitea.rule: "Host(`git.urmel.de`)"
traefik.http.routers.gitea.rule: "Host(`{{ gitea.url }}`)"
traefik.http.routers.gitea.tls: true
traefik.http.routers.gitea.tls.certResolver: hetzner
traefik.http.services.gitea-https.loadbalancer.server.port: 3000
{% if gitea.enable_ssh %}
traefik.tcp.routers.gitea.rule: "HostSNI(`*`)"
traefik.tcp.routers.gitea.entrypoints: public_ssh
traefik.tcp.services.gitea-ssh.loadbalancer.server.port: 22
{% endif %}
db:
image: docker.io/library/postgres:14
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_PASSWORD={{ gitea.db_password }}
- POSTGRES_DB=gitea
networks:
- internal
volumes:
- postgres:/var/lib/postgresql/data
- ./data/db:/var/lib/postgresql/data
networks:
internal:
@ -54,12 +54,3 @@ networks:
proxy:
name: traefik_exposed
external: true
volumes:
postgres:
name: gitea_postgres
gitea:
driver_opts:
type: nfs4
o: addr=217.100.0.2,rw,noatime,tcp,uid=1000,gid=1000
device: ":/mnt/Main/giteaData"