From 80490e775c62ec3c3859899f522bcc370ef62a80 Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 4 Oct 2024 13:42:40 +0200 Subject: [PATCH] [roles/service/gitweb] setup gitweb service --- roles/service/gitweb/files/default/public.cfg | 18 ++++ .../gitweb/files/default/public_header.html | 0 .../gitweb/files/default/public_ht.html | 2 + roles/service/gitweb/tasks/main.yml | 96 +++++++++++++++++++ .../vars/default/vars_nginx_vhost_custom.yml | 36 +++++++ 5 files changed, 152 insertions(+) create mode 100644 roles/service/gitweb/files/default/public.cfg create mode 100644 roles/service/gitweb/files/default/public_header.html create mode 100644 roles/service/gitweb/files/default/public_ht.html create mode 100644 roles/service/gitweb/tasks/main.yml create mode 100644 roles/service/gitweb/vars/default/vars_nginx_vhost_custom.yml diff --git a/roles/service/gitweb/files/default/public.cfg b/roles/service/gitweb/files/default/public.cfg new file mode 100644 index 0000000..e2f562a --- /dev/null +++ b/roles/service/gitweb/files/default/public.cfg @@ -0,0 +1,18 @@ +# +################################################ +### Managed by someone's ansible provisioner ### +################################################ +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# + +$projectroot = '/srv/gitolite/repositories/'; +$projects_list = '/srv/gitolite/projects.list'; +$export_ok = 'git-daemon-export-ok'; +$strict_export = '1'; +$site_header = '/etc/gitweb/public_header.html'; +$home_text = '/etc/gitweb/public_ht.html'; +$site_name = 'git.somenet.org'; +$home_link_str = 'SomeNet\'s public repos'; +$feature{'pathinfo'}{'default'} = [1]; +@git_base_url_list = ( "https://git.somenet.org", "git remote set-url --push origin ssh://git\@git.somenet.org:2", "git\@git.somenet.org:" ); diff --git a/roles/service/gitweb/files/default/public_header.html b/roles/service/gitweb/files/default/public_header.html new file mode 100644 index 0000000..e69de29 diff --git a/roles/service/gitweb/files/default/public_ht.html b/roles/service/gitweb/files/default/public_ht.html new file mode 100644 index 0000000..a8bc2a6 --- /dev/null +++ b/roles/service/gitweb/files/default/public_ht.html @@ -0,0 +1,2 @@ +

This server is running gitolite and is being administrated by someone. Send him ssh-keys for access.
+Contact someone via IRC: someone @ irc.somenet.org OR use email.

diff --git a/roles/service/gitweb/tasks/main.yml b/roles/service/gitweb/tasks/main.yml new file mode 100644 index 0000000..4599318 --- /dev/null +++ b/roles/service/gitweb/tasks/main.yml @@ -0,0 +1,96 @@ +##################################### +### someone"s ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +- name: install gitweb + apt: + pkg: + - fcgiwrap + - gitweb + state: present + policy_rc_d: 101 + tags: "online" + + +- name: add www-data user to group git + user: + name: "www-data" + groups: "git" + append: yes + createhome: no + state: present + + +- name: include vars_nginx_vhost_custom + include_vars: + file: "{{item}}" + name: vars_nginx_vhost_custom + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/vars_nginx_vhost_custom.yml" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/vars_nginx_vhost_custom.yml" + - "default/vars_nginx_vhost_custom.yml" + + +- name: configure gitweb vhost + include_role: + name: server/nginx/vhost-unified + vars: + vhost_name: "git.somenet.org" + vhost_custom: + vhost_custom_pre_server: "{{vars_nginx_vhost_custom.vhost_custom_pre_server}}" + vhost_custom: "{{vars_nginx_vhost_custom.vhost_custom}}" + + +- name: setup gitweb config dir + file: + path: "/etc/gitweb/" + state: directory + mode: 0755 + owner: "root" + group: "root" + + +- name: copy gitweb_public.cfg + copy: + src: "{{item}}" + dest: "/etc/gitweb/public.conf" + mode: 0644 + owner: "root" + group: "root" + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/public.cfg" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/public.cfg" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/public.cfg" + - "default/public.cfg" + + +- name: copy public_header.html + copy: + src: "{{item}}" + dest: "/etc/gitweb/public_header.html" + mode: 0644 + owner: "root" + group: "root" + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/public_header.html" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/public_header.html" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/public_header.html" + - "default/public_header.html" + + +- name: copy public_ht.html + copy: + src: "{{item}}" + dest: "/etc/gitweb/public_ht.html" + mode: 0644 + owner: "root" + group: "root" + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/public_ht.html" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/public_ht.html" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/public_ht.html" + - "default/public_ht.html" diff --git a/roles/service/gitweb/vars/default/vars_nginx_vhost_custom.yml b/roles/service/gitweb/vars/default/vars_nginx_vhost_custom.yml new file mode 100644 index 0000000..95c5394 --- /dev/null +++ b/roles/service/gitweb/vars/default/vars_nginx_vhost_custom.yml @@ -0,0 +1,36 @@ +##################################### +### someone"s ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +vhost_custom_pre_server: |- + +vhost_custom: |- + # clone via https + location ~ ^.*\.git/(HEAD|info/refs|objects/.*|git-(upload|receive)-pack)$ { + root /srv/gitolite/repositories/; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_PROJECT_ROOT /srv/gitolite/repositories/; + fastcgi_pass unix:/run/fcgiwrap.socket; + } + + # gitweb + root /usr/share/gitweb; + try_files $uri @gitweb; + location @gitweb { + gzip off; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param GITWEB_CONFIG /etc/gitweb/public.conf; + fastcgi_pass unix:/run/fcgiwrap.socket; + } + + # remote trailing slashes from path + location ~ ^/(.*)/$ { + rewrite ^/(.*)/$ /$1 permanent; + } -- 2.43.0