Verified Commit 35e5a8a4 authored by Giancarlo Razzolini's avatar Giancarlo Razzolini
Browse files

roles/aurweb: cgit and smartgit changes

Added a smartgit_socket option to the defaults. Reworked the tasks package
installation to look cleaner and also separated the cgit and git package installations
so we can trigger uwsgi reloads on updates. Changed the tubylaws repo update variable
to trigger the bylaws changes only when the tubylaws repository change, not the aurweb
one. Added tasks to install the apcu configuration, cgit uwsgi ini file, cgit rc file and
smartgit uwsgi ini file. Trigger an uwsgi reload in case the cgit-aurweb or git packages
change. Also added a few missing options to the aurweb configuration file. Rework the nginx
configuration file to use the cgit and smartgit uwsgi services.
parent 11dd3a54
......@@ -18,6 +18,7 @@ aurweb_db_user: 'aur'
aurweb_user: 'aur'
aurweb_socket: '/run/php-fpm/{{aurweb_user}}.socket'
cgit_socket: '/run/uwsgi/cgit.sock'
smartgit_socket: '/run/uwsgi/smartgit.sock'
aurweb_cache: 'apc'
aurweb_cache_pkginfo_ttl: '86400'
......
---
- name: install required packages
pacman: name=git,sudo,python-mysql-connector,python-pygit2,python-srcinfo,python-bleach,python-markdown,pyalpm,make,asciidoc,php-apcu,php-apcu-bc state=present
pacman:
state: present
name:
- asciidoc
- git
- highlight
- make
- php-apcu
- php-apcu-bc
- pyalpm
- python-bleach
- python-markdown
- python-mysql-connector
- python-pygit2
- python-srcinfo
- sudo
- uwsgi-plugin-cgi
- name: install the cgit package
pacman:
state: present
name:
- cgit-aurweb
register: cgit
- name: install the git package
pacman:
state: present
name:
- git
register: git
- name: make aur user
user: name="{{ aurweb_user }}" shell=/bin/bash createhome=yes
......@@ -24,7 +54,7 @@
version={{ tubylaws_version }}
become: true
become_user: "{{ aurweb_user }}"
register: release
register: tubylaws_release
- name: create necessary directories
file: path={{ aurweb_dir}}/{{ item }} state=directory owner={{ aurweb_user }} group={{ aurweb_user }}
......@@ -93,12 +123,15 @@
chdir: "{{ aurweb_dir }}/tu-bylaws"
become: true
become_user: "{{ aurweb_user }}"
when: tubylaws_release.changed
- name: Install Trusted User documentation
copy: src={{ aurweb_dir }}/tu-bylaws/tu-bylaws.html dest={{ aurweb_dir }}/web/html/trusted-user/tu-bylaws.html remote_src=yes
when: tubylaws_release.changed
- name: Install Trusted User documentation symlink
file: src=tu-bylaws.html dest={{ aurweb_dir }}/web/html/trusted-user/TUbylaws.html state=link
when: tubylaws_release.changed
- name: set up nginx
template: src=nginx.d.conf.j2 dest={{ aurweb_nginx_conf }} owner=root group=root mode=644
......@@ -118,6 +151,30 @@
- name: start and enable systemd socket
service: name=php-fpm@{{ aurweb_user }}.socket state=started enabled=true
- name: install apcu configuration
template: src=apcu.ini.j2 dest=/etc/php/conf.d/apcu.ini
- name: install cgit configuration
template: src=cgitrc.j2 dest="{{ aurweb_conf_dir }}/cgitrc"
- name: configure cgit uwsgi service
template: src=cgit.ini.j2 dest=/etc/uwsgi/vassals/cgit.ini owner={{ aurweb_user }} group=http mode=0644
- name: deploy new cgit release
become: true
become_user: "{{ aurweb_user }}"
file: path=/etc/uwsgi/vassals/cgit.ini state=touch
when: cgit.changed
- name: configure smartgit uwsgi service
template: src=smartgit.ini.j2 dest=/etc/uwsgi/vassals/smartgit.ini owner={{ aurweb_user }} group=http mode=0644
- name: deploy new smartgit release
become: true
become_user: "{{ aurweb_user }}"
file: path=/etc/uwsgi/vassals/smartgit.ini state=touch
when: git.changed
- name: create git repo dir
file: path={{ aurweb_git_dir }} state=directory owner={{aurweb_user}} group=http mode=0775
......
......@@ -4,6 +4,7 @@ socket = {{ cgit_socket }}
chown-socket = {{ aurweb_user }}:http
chmod-socket = 770
threads = 4
daemonize = /var/log/uwsgi/cgit-aurweb.log
cgi = /usr/share/webapps/cgit-aurweb/cgit.cgi
uid = {{ aurweb_user }}
......
......@@ -13,6 +13,8 @@ enable-maintenance = 0
localedir = {{ aurweb_dir }}/web/locale/
cache = {{ aurweb_cache }}
cache_pkginfo_ttl = {{ aurweb_cache_pkginfo_ttl }}
git_clone_uri_anon = https://{{ aurweb_domain }}/%s.git
git_clone_uri_priv = ssh://{{ aurweb_user }}@{{ aurweb_domain }}/%s.git
[ratelimit]
request_limit = {{ aurweb_request_limt }}
......@@ -21,6 +23,7 @@ window_length = {{ aurweb_window_length }}
[serve]
repo-path = {{ aurweb_git_dir }}
git-shell-cmd = /usr/bin/sh
ssh-cmdline = ssh {{ aurweb_user }}@{{ aurweb_domain }}
[aurblup]
db-path = {{ aurweb_dir }}/aurblup
......
upstream aurweb {
server unix://{{aurweb_socket}};
server unix://{{ aurweb_socket }};
}
upstream cgit {
server unix://{{ cgit_socket }};
}
upstream smartgit {
server unix://{{ smartgit_socket }};
}
server {
......@@ -32,16 +40,51 @@ server {
root {{ aurweb_dir }}/web/html;
index index.php;
location ~ ^/trusted-user/ {
break;
}
location ~ "^/([a-z0-9][a-z0-9.+_-]*?)(\.git)?/(git-(receive|upload)-pack|HEAD|info/refs|objects/(info/(http-)?alternates|packs)|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))$" {
include uwsgi_params;
uwsgi_pass smartgit;
uwsgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
uwsgi_param PATH_INFO /aur.git/$3;
uwsgi_param GIT_HTTP_EXPORT_ALL "";
uwsgi_param GIT_NAMESPACE $1;
uwsgi_param GIT_PROJECT_ROOT {{ aurweb_dir }};
}
location ~ ^/cgit {
include uwsgi_params;
rewrite ^/cgit/([^?/]+/[^?]*)?(?:\?(.*))?$ /cgit.cgi?url=$1&$2 last;
uwsgi_modifier1 9;
uwsgi_param CGIT_CONFIG {{ aurweb_conf_dir }}/cgitrc;
uwsgi_pass cgit;
}
location ~ ^/[^/]+\.php($|/) {
fastcgi_pass aurweb;
fastcgi_index index.php;
fastcgi_split_path_info ^(/[^/]+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
fastcgi_pass aurweb;
fastcgi_index index.php;
fastcgi_split_path_info ^(/[^/]+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
include fastcgi_params;
# Cache PHP Requests
#fastcgi_cache aur;
#fastcgi_cache_valid 200 5m;
#add_header X-Cache $upstream_cache_status;
# Required for caching to work
#fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
# Only apply cache when set
#fastcgi_cache_bypass $no_cache;
#fastcgi_no_cache $no_cache;
}
location ~ .* {
rewrite ^/(.*)$ /index.php/$1 last;
}
rewrite ^/(.*)$ /index.php/$1 last;
}
}
[uwsgi]
plugins = cgi
socket = {{ smartgit_socket }}
chown-socket = {{ aurweb_user }}:http
threads = 4
cgi = /usr/lib/git-core/git-http-backend
uid = {{ aurweb_user }}
gid = http
daemonize = /var/log/uwsgi/smartgit-aurweb.log
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment