diff options
| -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 | ||||
| -rw-r--r-- | roles/cosmos/tasks/main.yml | 12 | ||||
| -rw-r--r-- | roles/cosmos/templates/nginx.conf.j2 | 45 | ||||
| -rw-r--r-- | roles/personal/tasks/main.yml | 19 | ||||
| -rw-r--r-- | roles/personal/templates/nginx.conf.j2 | 45 |
10 files changed, 254 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" | ||
diff --git a/roles/cosmos/tasks/main.yml b/roles/cosmos/tasks/main.yml index c44505e..a50205c 100644 --- a/roles/cosmos/tasks/main.yml +++ b/roles/cosmos/tasks/main.yml | |||
| @@ -18,5 +18,17 @@ | |||
| 18 | validate: nginx-validate %s /etc/nginx/http.d/cosmos.conf | 18 | validate: nginx-validate %s /etc/nginx/http.d/cosmos.conf |
| 19 | notify: Reload nginx | 19 | notify: Reload nginx |
| 20 | 20 | ||
| 21 | - name: Provision cosmos CGit instance | ||
| 22 | ansible.builtin.include_role: | ||
| 23 | name: cgit | ||
| 24 | tags: | ||
| 25 | cgit | ||
| 26 | vars: | ||
| 27 | instance: "cosmos" | ||
| 28 | domain: "git.cosmos.party" | ||
| 29 | root_title: "Cosmos Party" | ||
| 30 | root_desc: "Here you can find all our git repositories" | ||
| 31 | scan_path: "/var/lib/git/repositories/" | ||
| 32 | |||
| 21 | tags: | 33 | tags: |
| 22 | - cosmos | 34 | - cosmos |
diff --git a/roles/cosmos/templates/nginx.conf.j2 b/roles/cosmos/templates/nginx.conf.j2 index b9b6c67..98879ac 100644 --- a/roles/cosmos/templates/nginx.conf.j2 +++ b/roles/cosmos/templates/nginx.conf.j2 | |||
| @@ -48,6 +48,51 @@ server { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | server { | 50 | server { |
| 51 | server_name git.cosmos.party; | ||
| 52 | |||
| 53 | listen unix:/var/run/nginx/http.sock; | ||
| 54 | listen 443 ssl; | ||
| 55 | listen [::]:443 ssl; | ||
| 56 | listen 443 quic; | ||
| 57 | listen [::]:443 quic; | ||
| 58 | |||
| 59 | http2 on; | ||
| 60 | http3 on; | ||
| 61 | |||
| 62 | add_header Alt-Svc 'h3=":443"; ma=86400'; | ||
| 63 | |||
| 64 | ssl_certificate /etc/ssl/cosmos.party.fullchain.pem; | ||
| 65 | ssl_certificate_key /etc/ssl/private/cosmos.party.key; | ||
| 66 | ssl_protocols TLSv1.2 TLSv1.3; | ||
| 67 | |||
| 68 | location ~ /.+/(info/refs|git-upload-pack) { | ||
| 69 | include /etc/nginx/fastcgi_params; | ||
| 70 | fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; | ||
| 71 | fastcgi_param PATH_INFO $uri; | ||
| 72 | fastcgi_param GIT_PROJECT_ROOT /var/lib/git/repositories/; | ||
| 73 | fastcgi_pass unix:/var/run/cgit.sock-1; | ||
| 74 | } | ||
| 75 | |||
| 76 | root /srv/http/git.cosmos.party/; | ||
| 77 | try_files $uri @cgit-static; | ||
| 78 | |||
| 79 | location @cgit-static { | ||
| 80 | root /usr/share/webapps/cgit/; | ||
| 81 | try_files $uri @cgit; | ||
| 82 | } | ||
| 83 | |||
| 84 | location @cgit { | ||
| 85 | include /etc/nginx/fastcgi_params; | ||
| 86 | fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi; | ||
| 87 | fastcgi_param CGIT_CONFIG /etc/cgitrc-cosmos; | ||
| 88 | fastcgi_param PATH_INFO $uri; | ||
| 89 | fastcgi_param QUERY_STRING $args; | ||
| 90 | fastcgi_param HTTP_HOST $server_name; | ||
| 91 | fastcgi_pass unix:/var/run/cgit.sock-1; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | |||
| 95 | server { | ||
| 51 | server_name andr.cosmos.party; | 96 | server_name andr.cosmos.party; |
| 52 | 97 | ||
| 53 | 98 | ||
diff --git a/roles/personal/tasks/main.yml b/roles/personal/tasks/main.yml index 6a9b7c7..8491d2e 100644 --- a/roles/personal/tasks/main.yml +++ b/roles/personal/tasks/main.yml | |||
| @@ -35,5 +35,24 @@ | |||
| 35 | mode: '0440' | 35 | mode: '0440' |
| 36 | notify: Reload nginx | 36 | notify: Reload nginx |
| 37 | 37 | ||
| 38 | - name: Provision personal CGit instance | ||
| 39 | ansible.builtin.include_role: | ||
| 40 | name: cgit | ||
| 41 | tags: | ||
| 42 | cgit | ||
| 43 | vars: | ||
| 44 | instance: "personal" | ||
| 45 | domain: "git.michalec.dev" | ||
| 46 | root_title: "Martin Michalec" | ||
| 47 | root_desc: "Here you can find all my git repositories" | ||
| 48 | scan_path: "/var/lib/git/repositories/cmmm/" | ||
| 49 | extra: | | ||
| 50 | section=cosmos | ||
| 51 | repo.url=cosmos/codebase | ||
| 52 | repo.name=codebase | ||
| 53 | repo.desc=The codebase | ||
| 54 | repo.owner=cmmm@cosmos.party | ||
| 55 | repo.path=/var/lib/git/repositories/codebase.git | ||
| 56 | |||
| 38 | tags: | 57 | tags: |
| 39 | - personal | 58 | - personal |
diff --git a/roles/personal/templates/nginx.conf.j2 b/roles/personal/templates/nginx.conf.j2 index 6b2d05a..6f6cee8 100644 --- a/roles/personal/templates/nginx.conf.j2 +++ b/roles/personal/templates/nginx.conf.j2 | |||
| @@ -83,3 +83,48 @@ server { | |||
| 83 | 83 | ||
| 84 | include /etc/nginx/http.d/michalec.dev.d/*.conf; | 84 | include /etc/nginx/http.d/michalec.dev.d/*.conf; |
| 85 | } | 85 | } |
| 86 | |||
| 87 | server { | ||
| 88 | server_name git.michalec.dev; | ||
| 89 | |||
| 90 | listen unix:/var/run/nginx/http.sock; | ||
| 91 | listen 443 ssl; | ||
| 92 | listen [::]:443 ssl; | ||
| 93 | listen 443 quic; | ||
| 94 | listen [::]:443 quic; | ||
| 95 | |||
| 96 | http2 on; | ||
| 97 | http3 on; | ||
| 98 | |||
| 99 | add_header Alt-Svc 'h3=":443"; ma=86400'; | ||
| 100 | |||
| 101 | ssl_certificate /etc/ssl/michalec.dev.fullchain.pem; | ||
| 102 | ssl_certificate_key /etc/ssl/private/michalec.dev.key; | ||
| 103 | ssl_protocols TLSv1.2 TLSv1.3; | ||
| 104 | |||
| 105 | root /srv/http/git.michalec.dev/; | ||
| 106 | try_files $uri @cgit-static; | ||
| 107 | |||
| 108 | location ~ /.+/(info/refs|git-upload-pack) { | ||
| 109 | include /etc/nginx/fastcgi_params; | ||
| 110 | fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; | ||
| 111 | fastcgi_param PATH_INFO $uri; | ||
| 112 | fastcgi_param GIT_PROJECT_ROOT /var/lib/git/repositories/cmmm/; | ||
| 113 | fastcgi_pass unix:/var/run/cgit.sock-1; | ||
| 114 | } | ||
| 115 | |||
| 116 | location @cgit-static { | ||
| 117 | root /usr/share/webapps/cgit/; | ||
| 118 | try_files $uri @cgit; | ||
| 119 | } | ||
| 120 | |||
| 121 | location @cgit { | ||
| 122 | include /etc/nginx/fastcgi_params; | ||
| 123 | fastcgi_param SCRIPT_FILENAME /usr/share/webapps/cgit/cgit.cgi; | ||
| 124 | fastcgi_param CGIT_CONFIG /etc/cgitrc-personal; | ||
| 125 | fastcgi_param PATH_INFO $uri; | ||
| 126 | fastcgi_param QUERY_STRING $args; | ||
| 127 | fastcgi_param HTTP_HOST $server_name; | ||
| 128 | fastcgi_pass unix:/var/run/cgit.sock-1; | ||
| 129 | } | ||
| 130 | } | ||
