diff options
Diffstat (limited to 'roles/cgit')
| -rw-r--r-- | roles/cgit/handlers/main.yml | 4 | ||||
| -rw-r--r-- | roles/cgit/tasks/main.yml | 52 | ||||
| -rw-r--r-- | roles/cgit/templates/cgitrc-instance.j2 | 15 | ||||
| -rw-r--r-- | roles/cgit/templates/cgitrc.j2 | 29 | ||||
| -rw-r--r-- | roles/cgit/templates/nginx.conf.j2 | 27 | ||||
| -rw-r--r-- | roles/cgit/templates/spawn-fcgi.cgit.j2 | 6 |
6 files changed, 133 insertions, 0 deletions
diff --git a/roles/cgit/handlers/main.yml b/roles/cgit/handlers/main.yml new file mode 100644 index 0000000..af9972a --- /dev/null +++ b/roles/cgit/handlers/main.yml | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | - name: "Restart spawn-fcgi.cgit" | ||
| 2 | ansible.builtin.service: | ||
| 3 | name: "spawn-fcgi.cgit" | ||
| 4 | state: restarted | ||
diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml new file mode 100644 index 0000000..15516d4 --- /dev/null +++ b/roles/cgit/tasks/main.yml | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | --- | ||
| 2 | - block: | ||
| 3 | - name: Install CGit and FastCGI wrapper packages | ||
| 4 | community.general.apk: | ||
| 5 | name: | ||
| 6 | - cgit | ||
| 7 | - fcgiwrap | ||
| 8 | - spawn-fcgi | ||
| 9 | - py3-pygments | ||
| 10 | state: present | ||
| 11 | |||
| 12 | - name: Ensure root CGit configuration exists | ||
| 13 | ansible.builtin.template: | ||
| 14 | src: cgitrc.j2 | ||
| 15 | dest: "/etc/cgitrc" | ||
| 16 | owner: root | ||
| 17 | group: root | ||
| 18 | mode: '0444' | ||
| 19 | |||
| 20 | - name: Ensure {{ instance }} CGit configuration exists | ||
| 21 | ansible.builtin.template: | ||
| 22 | src: cgitrc-instance.j2 | ||
| 23 | dest: "/etc/cgitrc-{{ instance }}" | ||
| 24 | owner: root | ||
| 25 | group: root | ||
| 26 | mode: '0444' | ||
| 27 | |||
| 28 | - name: Create OpenRC init script symlink | ||
| 29 | ansible.builtin.file: | ||
| 30 | src: /etc/init.d/spawn-fcgi | ||
| 31 | dest: "/etc/init.d/spawn-fcgi.cgit" | ||
| 32 | state: link | ||
| 33 | owner: root | ||
| 34 | group: root | ||
| 35 | |||
| 36 | - name: Deploy spawn-fcgi configuration | ||
| 37 | ansible.builtin.template: | ||
| 38 | src: spawn-fcgi.cgit.j2 | ||
| 39 | dest: "/etc/conf.d/spawn-fcgi.cgit" | ||
| 40 | owner: root | ||
| 41 | group: root | ||
| 42 | mode: '0444' | ||
| 43 | notify: Restart spawn-fcgi.cgit | ||
| 44 | |||
| 45 | - name: Ensure spawn-fcgi.git is started and enabled | ||
| 46 | ansible.builtin.service: | ||
| 47 | name: "spawn-fcgi.cgit" | ||
| 48 | state: started | ||
| 49 | enabled: true | ||
| 50 | |||
| 51 | tags: | ||
| 52 | - cgit | ||
diff --git a/roles/cgit/templates/cgitrc-instance.j2 b/roles/cgit/templates/cgitrc-instance.j2 new file mode 100644 index 0000000..2e55b67 --- /dev/null +++ b/roles/cgit/templates/cgitrc-instance.j2 | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | {# -*- Conf -*- #} | ||
| 2 | # {{ ansible_managed }} | ||
| 3 | |||
| 4 | include=/etc/cgitrc | ||
| 5 | |||
| 6 | root-readme=/srv/http/{{ domain }}/about.html | ||
| 7 | root-title={{ root_title }} | ||
| 8 | root-desc={{ root_desc }} | ||
| 9 | |||
| 10 | module-link=https://{{ domain }}/%s/tree/?id=%s | ||
| 11 | clone-url=https://{{ domain }}/$CGIT_REPO_URL ssh://git@{{ domain }}/$CGIT_REPO_URL | ||
| 12 | |||
| 13 | scan-path={{ scan_path }} | ||
| 14 | |||
| 15 | {{ extra }} | ||
diff --git a/roles/cgit/templates/cgitrc.j2 b/roles/cgit/templates/cgitrc.j2 new file mode 100644 index 0000000..9aee5f0 --- /dev/null +++ b/roles/cgit/templates/cgitrc.j2 | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | {# -*- Conf -*- #} | ||
| 2 | # {{ ansible_managed }} | ||
| 3 | |||
| 4 | enable-log-filecount=1 | ||
| 5 | enable-log-linecount=1 | ||
| 6 | enable-remote-branches=1 | ||
| 7 | enable-subject-links=1 | ||
| 8 | enable-git-config=1 | ||
| 9 | |||
| 10 | virtual-root=/ | ||
| 11 | |||
| 12 | local-time=1 | ||
| 13 | |||
| 14 | # logo= | ||
| 15 | |||
| 16 | source-filter=/usr/local/lib/cgit/filters/syntax-highlighting.sh | ||
| 17 | email-filter=lua:/usr/local/lib/cgit/filters/email-libravatar.lua | ||
| 18 | about-filter=/usr/local/lib/cgit/filters/about-formatting.sh | ||
| 19 | |||
| 20 | readme=master:README.org | ||
| 21 | |||
| 22 | # repository-sort=name | ||
| 23 | side-by-side-diffs=1 | ||
| 24 | |||
| 25 | snapshots=tar.gz | ||
| 26 | |||
| 27 | strict-export=git-daemon-export-ok | ||
| 28 | remove-suffix=1 | ||
| 29 | section-from-path=1 | ||
diff --git a/roles/cgit/templates/nginx.conf.j2 b/roles/cgit/templates/nginx.conf.j2 new file mode 100644 index 0000000..2483471 --- /dev/null +++ b/roles/cgit/templates/nginx.conf.j2 | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # -*- Nginx -*- | ||
| 2 | # {{ ansible_managed }} | ||
| 3 | |||
| 4 | server { | ||
| 5 | listen 443 ssl; | ||
| 6 | listen [::]:443 ssl; | ||
| 7 | server_name {{ domain }}; | ||
| 8 | |||
| 9 | ssl_certificate /etc/ssl/{{ domain | regex_replace('^git\\.', '') }}.fullchain.pem; | ||
| 10 | ssl_certificate_key /etc/ssl/private/{{ domain | regex_replace('^git\\.', '') }}.key; | ||
| 11 | |||
| 12 | root /usr/share/webapps/cgit/; | ||
| 13 | try_files $uri @cgit_{{ instance }}; | ||
| 14 | |||
| 15 | location / { | ||
| 16 | try_files $uri @cgit_{{ instance }}; | ||
| 17 | } | ||
| 18 | |||
| 19 | location @cgit_{{ instance }} { | ||
| 20 | include fastcgi_params; | ||
| 21 | fastcgi_param SCRIPT_FILENAME /usr/bin/cgit.cgi; | ||
| 22 | fastcgi_param PATH_INFO $uri; | ||
| 23 | fastcgi_param QUERY_STRING $args; | ||
| 24 | fastcgi_param HTTP_HOST $server_name; | ||
| 25 | fastcgi_pass 127.0.0.1:{{ port }}; | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/roles/cgit/templates/spawn-fcgi.cgit.j2 b/roles/cgit/templates/spawn-fcgi.cgit.j2 new file mode 100644 index 0000000..8cbfced --- /dev/null +++ b/roles/cgit/templates/spawn-fcgi.cgit.j2 | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | # {{ ansible_managed }} | ||
| 2 | FCGI_SOCKET=/var/run/cgit.sock | ||
| 3 | FCGI_PROGRAM="/usr/bin/fcgiwrap -f" | ||
| 4 | FCGI_USER=git | ||
| 5 | FCGI_GROUP=git | ||
| 6 | FCGI_EXTRA_OPTIONS="-U nginx -G nginx" | ||
