Gitea updated for the right host and to work with caddy.

This commit is contained in:
tanshu committed 2026-08-27 02:46:52 +00:00
1 parent b727fa7c00
commit 399f5c7a6a
10 files changed
+51 -55

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
server {
listen 80;
server_name {{ http_host }};
# location /_/static {
# alias /path/to/gitea/public;
# }
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
+3 -2
View File
@@ -2,7 +2,7 @@
# DO Community Playbooks: Docker # DO Community Playbooks: Docker
################################################# #################################################
--- ---
- hosts: gondor - hosts: monoco
become: true become: true
vars_files: vars_files:
- vars/default.yml - vars/default.yml
@@ -11,5 +11,6 @@
- user - user
- passthrough - passthrough
- sshkey - sshkey
- network
- gitea - gitea
- nginx - caddy
+5
View File
@@ -0,0 +1,5 @@
---
# Handlers for Caddy role
- name: Reload Caddy configuration
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
listen: "Reload Caddy"
+22
View File
@@ -0,0 +1,22 @@
---
- name: Read current Caddyfile
ansible.builtin.slurp:
path: "{{ caddyfile_path }}"
register: caddyfile_raw
- name: Decode Caddyfile content
set_fact:
caddyfile_content: "{{ caddyfile_raw['content'] | b64decode }}"
- name: Check if snippet already exists
set_fact:
snippet_present: "{{ snippet_block in caddyfile_content }}"
- name: Add snippet if missing
ansible.builtin.blockinfile:
path: "{{ caddyfile_path }}"
marker: "# {mark} Ansible managed Caddy snippet for {{ http_host }}"
block: "{{ snippet_block }}"
create: yes
when: not snippet_present
notify: "Reload Caddy"
+4 -2
View File
@@ -22,8 +22,8 @@
memory: "512M" memory: "512M"
memory_swap: "512M" memory_swap: "512M"
env: env:
USER_UID: "{{ getent_passwd[user][1] }}" USER_UID: "{{ ansible_facts['getent_passwd'][user][1] }}"
USER_GID: "{{ getent_passwd[user][2] }}" USER_GID: "{{ ansible_facts['getent_passwd'][user][2] }}"
published_ports: published_ports:
- "127.0.0.1:3000:3000" - "127.0.0.1:3000:3000"
- "127.0.0.1:2222:22" - "127.0.0.1:2222:22"
@@ -32,3 +32,5 @@
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
- "/home/{{ user }}/.ssh/:/data/git/.ssh" - "/home/{{ user }}/.ssh/:/data/git/.ssh"
networks:
- name: "{{ docker_network }}"
+8
View File
@@ -0,0 +1,8 @@
---
- name: "Ensure {{ container_name }} Docker network exists"
docker_network:
name: "{{ docker_network }}"
state: present
connected:
- "{{ caddy_container }}"
appends: yes
-2
View File
@@ -1,2 +0,0 @@
---
# Default variables for Nginx role
-6
View File
@@ -1,6 +0,0 @@
---
# Handlers for Nginx role
- name: Reload Nginx
service:
name: nginx
state: reloaded
-24
View File
@@ -1,24 +0,0 @@
---
# Tasks for Nginx role
- name: Check if Nginx conf file exists
stat:
path: "/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug:
msg: "No need to reload Nginx as sites-available entries have already been created"
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
+9
View File
@@ -6,4 +6,13 @@ http_url: "https://git.tanshu.com"
container_name: gitea container_name: gitea
container_image: gitea/gitea:latest container_image: gitea/gitea:latest
docker_network: "{{ container_name }}_net"
caddy_container: caddy
caddyfile_path: /var/lib/caddy/conf/Caddyfile
snippet_block: |
{{ http_host }} {
reverse_proxy {{ container_name }}:3000
}
user: 'git' user: 'git'