diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 11:31:02 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:36:51 -0700 |
| commit | 37304c0b775d3701318fcdb23f205ecddd47e6f0 (patch) | |
| tree | 339d5959d031adc6bb150db5dad1907a6bbd6aa8 | |
| parent | Add support for downloading zip files of repo snapshots (diff) | |
| download | site-configs-37304c0b775d3701318fcdb23f205ecddd47e6f0.zip | |
Adjust cgit files to be located in /htdocs/cgit
Given I want to run multiple sites from this host, this should make it a
little clearer by having *most* of the related files all in one place.
We still have /conf/cgitrc and /cache/cgit, but I think that is okay and
clear enough.
| -rw-r--r-- | roles/obsd_cgit/defaults/main.yml | 4 | ||||
| -rw-r--r-- | roles/obsd_cgit/meta/main.yml | 4 | ||||
| -rw-r--r-- | roles/obsd_cgit/tasks/main.yml | 84 | ||||
| -rw-r--r-- | roles/obsd_cgit/templates/cgitrc.j2 | 2 | ||||
| -rw-r--r-- | roles/obsd_cgit/templates/httpd.d/cgit.conf.j2 | 4 |
5 files changed, 70 insertions, 28 deletions
diff --git a/roles/obsd_cgit/defaults/main.yml b/roles/obsd_cgit/defaults/main.yml index 5a4855c..77e4d4f 100644 --- a/roles/obsd_cgit/defaults/main.yml +++ b/roles/obsd_cgit/defaults/main.yml @@ -1,4 +1,6 @@ obsd_cgit_domain: "{{ cgit_domain }}" +obsd_cgit_chroot: "/var/www" # Absolute path from /var/www chroot that httpd runs in -obsd_cgit_cache_dir: /cgit/cache +obsd_cgit_cache_dir: /cache/cgit obsd_cgit_repos_dir: /git/public +obsd_cgit_htdocs_dir: /htdocs/cgit diff --git a/roles/obsd_cgit/meta/main.yml b/roles/obsd_cgit/meta/main.yml deleted file mode 100644 index 13c7372..0000000 --- a/roles/obsd_cgit/meta/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -dependencies: - - role: obsd_httpd - - role: acme_client - - role: obsd_git diff --git a/roles/obsd_cgit/tasks/main.yml b/roles/obsd_cgit/tasks/main.yml index ec79515..d04d80a 100644 --- a/roles/obsd_cgit/tasks/main.yml +++ b/roles/obsd_cgit/tasks/main.yml @@ -3,38 +3,82 @@ name: cgit state: present -- name: Deploy cgit vhost fragment - ansible.builtin.template: - src: httpd.d/cgit.conf.j2 - dest: "{{ obsd_httpd_conf_d | default('/etc/httpd.d') }}/cgit.conf" - owner: root - group: wheel - mode: "0644" - notify: Reload httpd - -- name: Create cgit cache directory +- name: Create cgit directorys ansible.builtin.file: - path: "/var/www{{ obsd_cgit_cache_dir }}" + path: "{{ obsd_cgit_chroot }}{{ item }}" state: directory owner: www - group: daemon + group: www mode: "0755" + loop: + - "{{ obsd_cgit_cache_dir }}" + - "{{ obsd_cgit_htdocs_dir }}" + - "{{ obsd_cgit_htdocs_dir }}/cgi-bin" -- name: Compile markdown renderer into chroot - ansible.builtin.include_tasks: markdown.yml +- name: Check if original cgi-bin exists + ansible.builtin.stat: + path: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi" + register: obsd_cgit_cgi_stat + +- name: Move cgi-bin file from installation to htdocs + ansible.builtin.copy: + src: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi" + dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}/cgi-bin/cgit.cgi" + remote_src: true + owner: www + group: www + mode: "0755" + when: obsd_cgit_cgi_stat.stat.exists + +- name: Remove original cgit.cgi + ansible.builtin.file: + path: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi" + state: absent + +- name: Check if original cgit dir exists + ansible.builtin.stat: + path: "{{ obsd_cgit_chroot }}/cgit" + register: obsd_cgit_cgit_stat + +- name: Move cgit static files from installation to htdocs + ansible.builtin.copy: + src: "{{ obsd_cgit_chroot }}/cgit/*" + dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}/" + remote_src: true + owner: www + group: www + mode: "0644" + when: obsd_cgit_cgit_stat.stat.exists + +- name: Remove original cgit static files + ansible.builtin.file: + path: "{{ obsd_cgit_chroot }}/cgit" + state: absent - name: Copy extra html head file into chroot ansible.builtin.copy: src: head.html - dest: /var/www/cgit/ - owner: root - group: daemon + dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}" + owner: www + group: www mode: "0644" -- name: Deploy cgitrc configuration +- name: Copy cgitrc configuration into chroot ansible.builtin.template: src: cgitrc.j2 - dest: /var/www/conf/cgitrc + dest: "{{ obsd_cgit_chroot }}/conf/cgitrc" owner: www - group: daemon + group: www mode: "0644" + +- name: Compile markdown renderer into chroot + ansible.builtin.include_tasks: markdown.yml + +- name: Deploy cgit vhost fragment + ansible.builtin.template: + src: httpd.d/cgit.conf.j2 + dest: "{{ obsd_httpd_conf_d | default('/etc/httpd.d') }}/cgit.conf" + owner: root + group: wheel + mode: "0644" + notify: Reload httpd diff --git a/roles/obsd_cgit/templates/cgitrc.j2 b/roles/obsd_cgit/templates/cgitrc.j2 index b826ab3..9bb23e5 100644 --- a/roles/obsd_cgit/templates/cgitrc.j2 +++ b/roles/obsd_cgit/templates/cgitrc.j2 @@ -16,7 +16,7 @@ enable-http-clone=0 snapshots=zip about-filter=/bin/convert-markdown -head-include=/cgit/head.html +head-include={{ obsd_cgit_htdocs_dir }}/head.html max-atom-items=100 max-stats=year diff --git a/roles/obsd_cgit/templates/httpd.d/cgit.conf.j2 b/roles/obsd_cgit/templates/httpd.d/cgit.conf.j2 index a10b880..d309057 100644 --- a/roles/obsd_cgit/templates/httpd.d/cgit.conf.j2 +++ b/roles/obsd_cgit/templates/httpd.d/cgit.conf.j2 @@ -7,7 +7,7 @@ server "{{ obsd_cgit_domain }}" { # Serve cgit static files (cgit.css, cgit.png) directly from disk location "/cgit.*" { - root "/cgit" + root "/htdocs/cgit" no fastcgi } @@ -15,6 +15,6 @@ server "{{ obsd_cgit_domain }}" { no banner # Route any other cgit paths/actions via fastcgi - root "/cgi-bin/cgit.cgi" + root "/htdocs/cgit/cgi-bin/cgit.cgi" fastcgi socket "/run/slowcgi.sock" } |