summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed AbdelHalim <[email protected]>2026-07-17 15:40:22 +0200
committerAhmed AbdelHalim <[email protected]>2026-07-17 15:40:22 +0200
commit421d03ba5446415bfe831a8618ff8238fd0c382c (patch)
tree9e2994f0d87d8b88886e913882ee47ab133d210c
parent9f339c868128a99104472deaf84093ac36261a07 (diff)
Refactor proxy setup on cgit to simplify setup
-rw-r--r--configure.yml2
-rw-r--r--group_vars/homelab.ymlbin4347 -> 4326 bytes
-rw-r--r--host_vars/git.home.arpa.ymlbin569 -> 606 bytes
-rw-r--r--molecule/git/converge.yml11
-rw-r--r--molecule/git/molecule.yml11
-rw-r--r--roles/cgit/defaults/main.yml1
-rw-r--r--roles/cgit/handlers/main.yml14
-rw-r--r--roles/cgit/meta/argument_specs.yml10
-rw-r--r--roles/cgit/tasks/main.yml46
-rw-r--r--roles/cgit/templates/cgit.caddy.j25
-rw-r--r--roles/cgit/templates/cgit.nginx.conf.j228
-rw-r--r--roles/proxy/defaults/main.yml2
-rw-r--r--roles/proxy/meta/argument_specs.yml8
-rw-r--r--roles/proxy/meta/main.yml20
-rw-r--r--roles/proxy/tasks/main.yml4
-rw-r--r--service.yml2
16 files changed, 3 insertions, 161 deletions
diff --git a/configure.yml b/configure.yml
index 918812a6..540a51f4 100644
--- a/configure.yml
+++ b/configure.yml
@@ -90,7 +90,7 @@
- role: "vim"
- role: "wireguard"
- role: "gateway"
- - role: "proxy"
+ - role: "caddy"
- role: "wg_portal"
- role: "pihole"
- role: "prometheus"
diff --git a/group_vars/homelab.yml b/group_vars/homelab.yml
index ffc5eb07..cba875ac 100644
--- a/group_vars/homelab.yml
+++ b/group_vars/homelab.yml
Binary files differ
diff --git a/host_vars/git.home.arpa.yml b/host_vars/git.home.arpa.yml
index 99758953..e835dee9 100644
--- a/host_vars/git.home.arpa.yml
+++ b/host_vars/git.home.arpa.yml
Binary files differ
diff --git a/molecule/git/converge.yml b/molecule/git/converge.yml
index 8354d3ce..906de734 100644
--- a/molecule/git/converge.yml
+++ b/molecule/git/converge.yml
@@ -1,20 +1,9 @@
---
-- name: "Proxy configure"
- gather_facts: true
- hosts:
- - proxy.home.arpa
- vars:
- network_ipv4_address: "{{ ansible_facts['default_ipv4']['address'] }}"
- proxy_type: "caddy"
- roles:
- - role: "proxy"
-
- name: "Git configure"
gather_facts: true
hosts:
- git.home.arpa
vars:
network_ipv4_address: "{{ ansible_facts['default_ipv4']['address'] }}"
- cgit_proxy_host: "proxy.home.arpa"
roles:
- role: "cgit"
diff --git a/molecule/git/molecule.yml b/molecule/git/molecule.yml
index 335911db..98931d08 100644
--- a/molecule/git/molecule.yml
+++ b/molecule/git/molecule.yml
@@ -8,17 +8,6 @@ dependency:
driver:
name: podman
platforms:
- - name: proxy.home.arpa
- image: proxy
- dockerfile: Dockerfile.j2
- platform: "linux/amd64"
- pre_build_image: false
- privileged: true
- command: ${MOLECULE_COMMAND:-"/sbin/init"}
- tmpfs:
- "/tmp": "rw"
- "/run": "rw,exec"
- cgroupns_mode: host
- name: git.home.arpa
image: git
dockerfile: Dockerfile.j2
diff --git a/roles/cgit/defaults/main.yml b/roles/cgit/defaults/main.yml
index 02168d34..078eda16 100644
--- a/roles/cgit/defaults/main.yml
+++ b/roles/cgit/defaults/main.yml
@@ -6,4 +6,3 @@ cgit_title: "git"
cgit_description: "personal git repositories"
cgit_clone_prefix: "ssh://{{ cgit_ssh_user }}@{{ cgit_hostname }}"
cgit_ssh_user: "git"
-cgit_proxy_host: "proxy.home.arpa"
diff --git a/roles/cgit/handlers/main.yml b/roles/cgit/handlers/main.yml
index 52ffdbee..516733f7 100644
--- a/roles/cgit/handlers/main.yml
+++ b/roles/cgit/handlers/main.yml
@@ -4,17 +4,3 @@
ansible.builtin.service:
name: lighttpd
state: restarted
-
-- name: "Restart caddy"
- become: true
- delegate_to: "{{ cgit_proxy_host }}"
- ansible.builtin.service:
- name: caddy
- state: restarted
-
-- name: "Restart nginx"
- become: true
- delegate_to: "{{ cgit_proxy_host }}"
- ansible.builtin.service:
- name: nginx
- state: restarted
diff --git a/roles/cgit/meta/argument_specs.yml b/roles/cgit/meta/argument_specs.yml
index 652598de..48676be9 100644
--- a/roles/cgit/meta/argument_specs.yml
+++ b/roles/cgit/meta/argument_specs.yml
@@ -4,7 +4,7 @@ argument_specs:
options:
cgit_hostname:
type: "str"
- description: "Public hostname for cgit (e.g. git.example.com)"
+ description: "Hostname for cgit (e.g. git.example.com)"
default: "git.example.com"
cgit_port:
type: "int"
@@ -30,11 +30,3 @@ argument_specs:
type: "str"
description: "System user for SSH git push access"
default: "git"
- cgit_proxy_host:
- type: "str"
- description: "Inventory hostname of the proxy container to deploy vhost on"
- default: "proxy.home.arpa"
- cgit_public_hostname:
- type: "str"
- description: "Optional public hostname for cgit (e.g. git.a14m.dev); enables public vhost block with TLS"
- required: false
diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml
index 17a5675b..c5eeea3b 100644
--- a/roles/cgit/tasks/main.yml
+++ b/roles/cgit/tasks/main.yml
@@ -52,52 +52,6 @@
mode: "0644"
notify: "Restart lighttpd"
-- name: "Deploy caddy vhost on proxy"
- when: hostvars[cgit_proxy_host]['proxy_type'] == "caddy"
- delegate_to: "{{ cgit_proxy_host }}"
- block:
- - name: "Ensure caddy sites directory exists"
- become: true
- ansible.builtin.file:
- path: "/etc/caddy/sites"
- state: directory
- owner: "root"
- group: "caddy"
- mode: "0750"
-
- - name: "Deploy caddy vhost"
- become: true
- ansible.builtin.template:
- src: "cgit.caddy.j2"
- dest: "/etc/caddy/sites/{{ cgit_hostname }}.caddy"
- owner: "root"
- group: "caddy"
- mode: "0640"
- notify: "Restart caddy"
-
-- name: "Deploy nginx vhost on proxy"
- when: hostvars[cgit_proxy_host]['proxy_type'] == "nginx"
- delegate_to: "{{ cgit_proxy_host }}"
- block:
- - name: "Ensure nginx vhosts directory exists"
- become: true
- ansible.builtin.file:
- path: "/etc/nginx/vhosts.d"
- state: directory
- owner: "root"
- group: "root"
- mode: "0755"
-
- - name: "Deploy nginx vhost"
- become: true
- ansible.builtin.template:
- src: "cgit.nginx.conf.j2"
- dest: "/etc/nginx/vhosts.d/{{ cgit_hostname }}.conf"
- owner: "root"
- group: "root"
- mode: "0644"
- notify: "Restart nginx"
-
- name: "Enable and start services"
become: true
ansible.builtin.service:
diff --git a/roles/cgit/templates/cgit.caddy.j2 b/roles/cgit/templates/cgit.caddy.j2
deleted file mode 100644
index c0a87a18..00000000
--- a/roles/cgit/templates/cgit.caddy.j2
+++ /dev/null
@@ -1,5 +0,0 @@
-{% if cgit_public_hostname is defined %}
-{{ cgit_public_hostname }} {
- reverse_proxy {{ network_ipv4_address }}:{{ cgit_port }}
-}
-{% endif %}
diff --git a/roles/cgit/templates/cgit.nginx.conf.j2 b/roles/cgit/templates/cgit.nginx.conf.j2
deleted file mode 100644
index 4ac0ae43..00000000
--- a/roles/cgit/templates/cgit.nginx.conf.j2
+++ /dev/null
@@ -1,28 +0,0 @@
-server {
- listen 80;
- listen [::]:80;
- server_name {{ cgit_hostname }};
- location / {
- proxy_pass http://{{ network_ipv4_address }}:{{ cgit_port }};
- }
-}
-{% if cgit_public_hostname is defined %}
-
-server {
- listen 80;
- listen [::]:80;
- server_name {{ cgit_public_hostname }};
- return 301 https://$server_name$request_uri;
-}
-
-server {
- listen 443 ssl http2;
- listen [::]:443 ssl http2;
- server_name {{ cgit_public_hostname }};
- ssl_certificate {{ nginx_ssl_certificate }};
- ssl_certificate_key {{ nginx_ssl_certificate_key }};
- location / {
- proxy_pass http://{{ network_ipv4_address }}:{{ cgit_port }};
- }
-}
-{% endif %}
diff --git a/roles/proxy/defaults/main.yml b/roles/proxy/defaults/main.yml
deleted file mode 100644
index 5f0d40a0..00000000
--- a/roles/proxy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-proxy_type: "nginx"
diff --git a/roles/proxy/meta/argument_specs.yml b/roles/proxy/meta/argument_specs.yml
deleted file mode 100644
index ee11aa1a..00000000
--- a/roles/proxy/meta/argument_specs.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-argument_specs:
- main:
- options:
- proxy_type:
- type: "str"
- description: "Reverse proxy to use: 'nginx' or 'caddy'"
- default: "nginx"
diff --git a/roles/proxy/meta/main.yml b/roles/proxy/meta/main.yml
deleted file mode 100644
index 5cc03ec2..00000000
--- a/roles/proxy/meta/main.yml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-dependencies: []
-galaxy_info:
- author: "a14m"
- description: "Conditionally configure nginx or caddy reverse proxy based on proxy_type"
- license: "MIT"
- min_ansible_version: "2.18"
- platforms:
- - name: "ArchLinux"
- versions:
- - "all"
- - name: "Ubuntu"
- versions:
- - "noble"
- - name: "Debian"
- versions:
- - "bookworm"
- - name: "Alpine"
- versions:
- - "all"
diff --git a/roles/proxy/tasks/main.yml b/roles/proxy/tasks/main.yml
deleted file mode 100644
index c5626725..00000000
--- a/roles/proxy/tasks/main.yml
+++ /dev/null
@@ -1,4 +0,0 @@
----
-- name: "Setup proxy"
- ansible.builtin.include_role:
- name: "{{ proxy_type }}"
diff --git a/service.yml b/service.yml
index 18a89540..c35aab6a 100644
--- a/service.yml
+++ b/service.yml
@@ -4,7 +4,7 @@
hosts:
- proxy.home.arpa
roles:
- - role: "proxy"
+ - role: "caddy"
- name: "Git configure"
gather_facts: true