diff options
Diffstat (limited to 'roles/cgit')
| -rw-r--r-- | roles/cgit/tasks/main.yml | 47 | ||||
| -rw-r--r-- | roles/cgit/templates/cgitrc.j2 | 26 | ||||
| -rw-r--r-- | roles/cgit/templates/site-cgit.conf.j2 | 21 |
3 files changed, 94 insertions, 0 deletions
diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml new file mode 100644 index 0000000..44f9459 --- /dev/null +++ b/roles/cgit/tasks/main.yml @@ -0,0 +1,47 @@ +--- +- name: Install cgit and FastCGI dependencies + ansible.builtin.apt: + name: + - cgit + - fcgiwrap + - python3-pygments + - python3-markdown + state: present + +- name: Ensure Git repositories root directory exists + ansible.builtin.file: + path: "{{ cgit_repos_path }}" + state: directory + owner: www-data + group: www-data + mode: "0755" + +- name: Deploy /etc/cgitrc configuration + ansible.builtin.template: + src: cgitrc.j2 + dest: /etc/cgitrc + owner: root + group: root + mode: "0644" + +- name: Ensure fcgiwrap socket/service is enabled and running + ansible.builtin.systemd: + name: fcgiwrap.socket + enabled: true + state: started + +- name: Deploy Nginx virtual host for cgit + ansible.builtin.template: + src: site-cgit.conf.j2 + dest: /etc/nginx/sites-available/cgit.conf + owner: root + group: root + mode: "0644" + notify: Reload nginx + +- name: Enable Nginx virtual host for cgit + ansible.builtin.file: + src: /etc/nginx/sites-available/cgit.conf + dest: /etc/nginx/sites-enabled/cgit.conf + state: link + notify: Reload nginx diff --git a/roles/cgit/templates/cgitrc.j2 b/roles/cgit/templates/cgitrc.j2 new file mode 100644 index 0000000..0cae2ab --- /dev/null +++ b/roles/cgit/templates/cgitrc.j2 @@ -0,0 +1,26 @@ +# /etc/cgitrc - Managed by Ansible +css=/cgit-css/cgit.css +logo=/cgit-css/cgit.png +favicon=/cgit-css/favicon.ico + +root-title={{ cgit_title }} +root-desc={{ cgit_description }} +virtual-root=/ + +enable-index-links=1 +enable-index-owner=0 +enable-commit-graph=1 +enable-log-filecount=1 +enable-log-linecount=1 +snapshots=tar.gz zip + +about-filter=/usr/lib/cgit/filters/about-formatting.sh +source-filter=/usr/lib/cgit/filters/syntax-highlighting.py + +readme=:README.md +readme=:readme.md +readme=:README.rst +readme=:README.txt +readme=:README + +scan-path={{ cgit_repos_path }} diff --git a/roles/cgit/templates/site-cgit.conf.j2 b/roles/cgit/templates/site-cgit.conf.j2 new file mode 100644 index 0000000..557c364 --- /dev/null +++ b/roles/cgit/templates/site-cgit.conf.j2 @@ -0,0 +1,21 @@ +server { + listen 80; + listen [::]:80; + server_name {{ cgit_domain }}; + + root /usr/share/cgit; + try_files $uri @cgit; + + location ~* ^/cgit-css/(.*)$ { + alias /usr/share/cgit/$1; + } + + location @cgit { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_pass unix:/run/fcgiwrap.socket; + } +} |
