summaryrefslogtreecommitdiffstats
path: root/roles
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
commit22988554510dd5d76df4037cebe8e6662f4dbc61 (patch)
tree9e2994f0d87d8b88886e913882ee47ab133d210c /roles
parent92ba528a34337b59408e41b124aafc8946439feb (diff)
Refactor proxy setup on cgit to simplify setup
Diffstat (limited to 'roles')
-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
10 files changed, 1 insertions, 137 deletions
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 }}"