Gitea updated for the right host and to work with caddy.
This commit is contained in:
1 parent
b727fa7c00
commit
399f5c7a6a
10 files changed
+51
-55
No files matched your search
@@ -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
@@ -2,7 +2,7 @@
|
||||
# DO Community Playbooks: Docker
|
||||
#################################################
|
||||
---
|
||||
- hosts: gondor
|
||||
- hosts: monoco
|
||||
become: true
|
||||
vars_files:
|
||||
- vars/default.yml
|
||||
@@ -11,5 +11,6 @@
|
||||
- user
|
||||
- passthrough
|
||||
- sshkey
|
||||
- network
|
||||
- gitea
|
||||
- nginx
|
||||
- caddy
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -22,8 +22,8 @@
|
||||
memory: "512M"
|
||||
memory_swap: "512M"
|
||||
env:
|
||||
USER_UID: "{{ getent_passwd[user][1] }}"
|
||||
USER_GID: "{{ getent_passwd[user][2] }}"
|
||||
USER_UID: "{{ ansible_facts['getent_passwd'][user][1] }}"
|
||||
USER_GID: "{{ ansible_facts['getent_passwd'][user][2] }}"
|
||||
published_ports:
|
||||
- "127.0.0.1:3000:3000"
|
||||
- "127.0.0.1:2222:22"
|
||||
@@ -32,3 +32,5 @@
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- "/home/{{ user }}/.ssh/:/data/git/.ssh"
|
||||
networks:
|
||||
- name: "{{ docker_network }}"
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: "Ensure {{ container_name }} Docker network exists"
|
||||
docker_network:
|
||||
name: "{{ docker_network }}"
|
||||
state: present
|
||||
connected:
|
||||
- "{{ caddy_container }}"
|
||||
appends: yes
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
# Default variables for Nginx role
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
# Handlers for Nginx role
|
||||
- name: Reload Nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
@@ -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
|
||||
@@ -6,4 +6,13 @@ http_url: "https://git.tanshu.com"
|
||||
container_name: gitea
|
||||
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'
|
||||
Reference in new issue
Block a user