From b232b894c3cbe087c8d504e91637dcf62199eed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 29 Jul 2021 17:00:20 +0200 Subject: Bump to third revision of homelab --- roles/cgit/defaults/main.yml | 7 +++- roles/cgit/meta/main.yml | 12 +++---- roles/cgit/tasks/main.yml | 48 ++++++++------------------- roles/cgit/templates/conf-cgitrc.j2 | 41 +++++++++++++++++++++++ roles/cgit/templates/conf-footer.html.j2 | 3 ++ roles/cgit/templates/etc-httpd.d-cgit.conf.j2 | 10 +++--- roles/cgit/templates/var-www-conf-cgitrc.j2 | 39 ---------------------- 7 files changed, 72 insertions(+), 88 deletions(-) create mode 100644 roles/cgit/templates/conf-cgitrc.j2 create mode 100644 roles/cgit/templates/conf-footer.html.j2 delete mode 100644 roles/cgit/templates/var-www-conf-cgitrc.j2 (limited to 'roles/cgit') diff --git a/roles/cgit/defaults/main.yml b/roles/cgit/defaults/main.yml index ffbca1d..9fe8961 100644 --- a/roles/cgit/defaults/main.yml +++ b/roles/cgit/defaults/main.yml @@ -6,8 +6,12 @@ cgit_user: "git" cgit_group: "git" +cgit_instance: "cgit" + cgit_git_dir: "/data/git" -cgit_git_dir_chroot: "/htdocs/cgit" +cgit_chroot_dir: "/var/www" + +cgit_ip: 0.0.0.0 cgit_port: 1235 cgit_authenticate: false @@ -16,3 +20,4 @@ cgit__logo: "http://rgoncalves.se/logo.png" cgit__css: "http://rgoncalves.se/style/cgit.css" cgit__root_desc: "development hub" cgit__root_readme: "http://rgoncalves.se" +cgit__footer: "/conf/footer.html" diff --git a/roles/cgit/meta/main.yml b/roles/cgit/meta/main.yml index 02b67be..a25f289 100644 --- a/roles/cgit/meta/main.yml +++ b/roles/cgit/meta/main.yml @@ -1,9 +1,5 @@ - -# cgit ~~ roles/cgit/meta/main.yml -# Meta parameters - ---- - dependencies: - - { role: git, tags: "dependency" } - - { role: httpd_pre, tags: "dependency" } + - role: git + tags: dependency + - role: httpd_pre + tags: dependency diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml index 6b52bd7..fa68415 100644 --- a/roles/cgit/tasks/main.yml +++ b/roles/cgit/tasks/main.yml @@ -1,21 +1,22 @@ - -# cgit ~~ roles/cgit/tasks/main.yml -# cgit web interface - ---- - - name: ensure cgit is installed package: name: cgit state: present -- name: generate cgit configuration file +- name: generate cgit configuration files template: - src: var-www-conf-cgitrc.j2 - dest: /var/www/conf/cgitrc + src: "{{ item.template }}" + dest: "{{ item.file }}" owner: "0" group: "0" mode: "0644" + loop: + - template: conf-cgitrc.j2 + file: "{{ cgit_chroot_dir }}/conf/cgitrc" + - template: conf-footer.html.j2 + file: "{{ cgit_chroot_dir }}/conf/footer.html" + - template: etc-httpd.d-cgit.conf.j2 + file: /etc/httpd.d/cgit.conf - name: generate cgit configuration for httpd template: @@ -28,7 +29,7 @@ - name: copy utility in httpd chroot copy: src: "/bin/{{ item }}" - dest: /var/www/bin + dest: "{{ cgit_chroot_dir }}/bin" mode: preserve remote_src: true loop: @@ -38,34 +39,11 @@ - name: copy about-filter generator copy: src: about-filter.sh - dest: /var/www/bin/about-filter.sh + dest: "{{ cgit_chroot_dir }}/bin/about-filter.sh" owner: "0" group: "0" mode: "0755" -- name: ensure cgit web directory exists - file: - path: /var/www/{{ cgit_git_dir_chroot }} - owner: "{{ cgit_user }}" - group: daemon - state: directory - mode: "0755" - -- name: include nfsclient for remote dir - include_role: - name: nfsclient - vars: - nfsclient_dir: "/var/www/{{ cgit_git_dir_chroot }}" - nfsclient_server_dir: "{{ global.nfs_server_dir }}/{{ ansible_host }}/git" - #nfsclient_server: "{{ global.nfs_server }}" - -- name: chown git directory to git - file: - path: /data/git - owner: "{{ cgit_user }}" - group: "{{ cgit_group }}" - state: directory - - name: start and enable slowcgi service service: name: slowcgi @@ -76,5 +54,5 @@ debug: msg: | Please provide a password using htpasswd, - in /htpasswd/cgit + in "{{ cgit_chroot_dir }}/htpasswd/cgit" when: cgit_authenticate diff --git a/roles/cgit/templates/conf-cgitrc.j2 b/roles/cgit/templates/conf-cgitrc.j2 new file mode 100644 index 0000000..1fc283f --- /dev/null +++ b/roles/cgit/templates/conf-cgitrc.j2 @@ -0,0 +1,41 @@ + +# cgit ~~ /var/www/conf/cgitrc +# managed by Ansible + +# visuals +css={{ cgit__css }} +logo={{ cgit__logo }} +favicon={{ cgit__favicon }} +footer={{ cgit__footer }} + +# readme +readme=:README.md +readme=:README.org +readme=:README +readme=:.README.md +readme=:.README +about-filter=/bin/about-filter.sh + +# features +enable-commit-graph=1 +enable-http-clone=1 +enable-index-links=1 +max-stats=quarter +robots=noindex, nofollow +localtime=1 + +# git +clone-url=git://git.{{ global.domain_name }}/$CGIT_REPO_URL ssh://git@git.{{ global.domain_name }}/$CGIT_REPO_URL http://git.{{ global.domain_name }}/$CGIT_REPO_URL + +# instance id +root-title=git.{{ global.domain_name }} +root-desc={{ cgit__root_desc }} +root-readme={{ cgit__root_readme }} + +# archives +snapshots=tar.gz + +# sections +section-from-path=1 +section-sort=1 +scan-path={{ cgit_git_dir }} diff --git a/roles/cgit/templates/conf-footer.html.j2 b/roles/cgit/templates/conf-footer.html.j2 new file mode 100644 index 0000000..66ca627 --- /dev/null +++ b/roles/cgit/templates/conf-footer.html.j2 @@ -0,0 +1,3 @@ + +remember that computers suck. + diff --git a/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 b/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 index 6fb8e98..b77ca35 100644 --- a/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 +++ b/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 @@ -2,19 +2,19 @@ # httpd ~~ /etc/httpd.d/cgit.conf" # managed by Ansible -ext_ip="0.0.0.0" server "cgit" { - listen on $ext_ip port {{ cgit_port }} + listen on "{{ cgit_ip }}" port {{ cgit_port }} {% if cgit_authenticate %} authenticate "realm" with "/htpasswd/cgit" {% endif %} - # serve cgit static files directly: cgit.css and cgit.png + # cgit location "/cgit.*" { root "/cgit" - no fastcgi + no fastcgi } - # cgit CGI + + # fastcgi root "/cgi-bin/cgit.cgi" fastcgi socket "/run/slowcgi.sock" } diff --git a/roles/cgit/templates/var-www-conf-cgitrc.j2 b/roles/cgit/templates/var-www-conf-cgitrc.j2 deleted file mode 100644 index 8be36ce..0000000 --- a/roles/cgit/templates/var-www-conf-cgitrc.j2 +++ /dev/null @@ -1,39 +0,0 @@ - -# cgit ~~ /var/www/conf/cgitrc -# managed by Ansible - -# visuals -css={{ cgit__css }} -logo={{ cgit__logo }} -favicon={{ cgit__favicon }} - -# readme -readme=:README.md -readme=:README.org -readme=:README -readme=:.README.md -readme=:.README -about-filter=/bin/about-filter.sh - -# features -enable-commit-graph=1 -enable-http-clone=1 -enable-index-links=1 -max-stats=quarter -robots=noindex, nofollow - -# git -clone-url=git://git.{{ global.domain_name }}/$CGIT_REPO_URL ssh://git@git.{{ global.domain_name }}/$CGIT_REPO_URL http://git.{{ global.domain_name }}/$CGIT_REPO_URL - -# instance id -root-title=git.{{ global.domain_name }} -root-desc={{ cgit__root_desc }} -root-readme={{ cgit__root_readme }} - -# archives -snapshots=tar.gz - -# sections -section-from-path=1 -section-sort=1 -scan-path={{ cgit_git_dir_chroot }} -- cgit v1.2.3