From 22988554510dd5d76df4037cebe8e6662f4dbc61 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Fri, 17 Jul 2026 15:40:22 +0200 Subject: Refactor proxy setup on cgit to simplify setup --- roles/cgit/defaults/main.yml | 1 - roles/cgit/handlers/main.yml | 14 ---------- roles/cgit/meta/argument_specs.yml | 10 +------ roles/cgit/tasks/main.yml | 46 --------------------------------- roles/cgit/templates/cgit.caddy.j2 | 5 ---- roles/cgit/templates/cgit.nginx.conf.j2 | 28 -------------------- roles/proxy/defaults/main.yml | 2 -- roles/proxy/meta/argument_specs.yml | 8 ------ roles/proxy/meta/main.yml | 20 -------------- roles/proxy/tasks/main.yml | 4 --- 10 files changed, 1 insertion(+), 137 deletions(-) delete mode 100644 roles/cgit/templates/cgit.caddy.j2 delete mode 100644 roles/cgit/templates/cgit.nginx.conf.j2 delete mode 100644 roles/proxy/defaults/main.yml delete mode 100644 roles/proxy/meta/argument_specs.yml delete mode 100644 roles/proxy/meta/main.yml delete mode 100644 roles/proxy/tasks/main.yml (limited to 'roles') 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 }}" -- cgit v1.2.3