summaryrefslogtreecommitdiff
path: root/roles/gitolite/http/tasks/nginx-vhost.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/gitolite/http/tasks/nginx-vhost.yml')
-rw-r--r--roles/gitolite/http/tasks/nginx-vhost.yml60
1 files changed, 60 insertions, 0 deletions
diff --git a/roles/gitolite/http/tasks/nginx-vhost.yml b/roles/gitolite/http/tasks/nginx-vhost.yml
new file mode 100644
index 00000000..6b7d2bd0
--- /dev/null
+++ b/roles/gitolite/http/tasks/nginx-vhost.yml
@@ -0,0 +1,60 @@
+---
+- name: compute nginx locations directives
+ set_fact:
+ nginx_locations_base:
+ '= /':
+ return: "303 /cgit/"
+ '/cgit-css/':
+ alias: "/usr/share/cgit/"
+ nginx_locations_logo: {}
+ nginx_locations_main:
+ '/cgit/':
+ custom: |-
+ include fastcgi_params;
+ fastcgi_split_path_info ^(/cgit)(.*)$;
+
+ fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ fastcgi_param QUERY_STRING $args;
+ fastcgi_param HTTP_HOST $server_name;
+ fastcgi_param CGIT_CONFIG {{ gitolite_base_path }}/{{ gitolite_instance.key }}/cgitrc;
+
+ fastcgi_pass unix:/run/fcgiwrap/gitolite-{{ gitolite_instance.key }}.sock;
+ nginx_locations_git_backend: {}
+
+- name: compute nginx extra location directive for logo
+ when: "'logo' in gitolite_instance.value.http"
+ set_fact:
+ nginx_locations_logo:
+ '= /logo.png':
+ alias: "/usr/local/share/cgit/{{ gitolite_instance.key }}.png"
+
+- name: compute nginx extra location directive for git_backend
+ when: "'enable_git_backend' in gitolite_instance.value.http and gitolite_instance.value.http.enable_git_backend"
+ set_fact:
+ nginx_locations_git_backend:
+ '~ ^.*/git-receive-pack$':
+ return: "403"
+ '~ ^.*/(HEAD|info/refs|objects/(info/.*|[0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))|git-upload-pack)$':
+ custom: |-
+ include fastcgi_params;
+
+ fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
+ fastcgi_param PATH_INFO $uri;
+ fastcgi_param GIT_PROJECT_ROOT {{ gitolite_base_path }}/{{ gitolite_instance.key }}/repositories;
+
+ fastcgi_pass unix:/run/fcgiwrap/gitolite-{{ gitolite_instance.key }}.sock;
+
+- name: install nginx vhost
+ vars:
+ nginx_vhost:
+ name: "gitolite-{{ gitolite_instance.key }}"
+ template: generic
+ tls: "{{ gitolite_instance.value.http.tls }}"
+ hostnames: "{{ gitolite_instance.value.http.hostnames }}"
+ logs:
+ access: "/var/log/nginx/git-{{ gitolite_instance.key }}_access.log"
+ error: "/var/log/nginx/git-{{ gitolite_instance.key }}_error.log"
+ locations: "{{ nginx_locations_base | combine(nginx_locations_logo) | combine(nginx_locations_main) | combine(nginx_locations_git_backend) }}"
+ include_role:
+ name: nginx/vhost