From 0f822dc490f3f90138b83fd9a323d0d37ef9512b Mon Sep 17 00:00:00 2001 From: binary Date: Thu, 18 Mar 2021 15:31:25 +0100 Subject: Variables refactoring and http auth. support --- roles/cgit/defaults/main.yml | 18 +++++++++++++ roles/cgit/tasks/main.yml | 21 ++++++++++----- roles/cgit/templates/cgit.httpd.conf.j2 | 17 ------------ roles/cgit/templates/cgitrc.j2 | 39 --------------------------- roles/cgit/templates/etc-httpd.d-cgit.conf.j2 | 20 ++++++++++++++ roles/cgit/templates/var-www-conf-cgitrc.j2 | 39 +++++++++++++++++++++++++++ roles/cgit/vars/main.yml | 17 ------------ 7 files changed, 92 insertions(+), 79 deletions(-) create mode 100644 roles/cgit/defaults/main.yml delete mode 100644 roles/cgit/templates/cgit.httpd.conf.j2 delete mode 100644 roles/cgit/templates/cgitrc.j2 create mode 100644 roles/cgit/templates/etc-httpd.d-cgit.conf.j2 create mode 100644 roles/cgit/templates/var-www-conf-cgitrc.j2 delete mode 100644 roles/cgit/vars/main.yml diff --git a/roles/cgit/defaults/main.yml b/roles/cgit/defaults/main.yml new file mode 100644 index 0000000..ffbca1d --- /dev/null +++ b/roles/cgit/defaults/main.yml @@ -0,0 +1,18 @@ + +# cgit ~~ roles/cgit/defaults/main.yml +# default vars for cgit role + +--- + +cgit_user: "git" +cgit_group: "git" +cgit_git_dir: "/data/git" +cgit_git_dir_chroot: "/htdocs/cgit" +cgit_port: 1235 +cgit_authenticate: false + +cgit__favicon: "http://rgoncalves.se/logo.png" +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" diff --git a/roles/cgit/tasks/main.yml b/roles/cgit/tasks/main.yml index 8022093..6b52bd7 100644 --- a/roles/cgit/tasks/main.yml +++ b/roles/cgit/tasks/main.yml @@ -11,7 +11,7 @@ - name: generate cgit configuration file template: - src: cgitrc.j2 + src: var-www-conf-cgitrc.j2 dest: /var/www/conf/cgitrc owner: "0" group: "0" @@ -19,7 +19,7 @@ - name: generate cgit configuration for httpd template: - src: cgit.httpd.conf.j2 + src: etc-httpd.d-cgit.conf.j2 dest: /etc/httpd.d/cgit.conf owner: "0" group: "0" @@ -59,13 +59,22 @@ nfsclient_server_dir: "{{ global.nfs_server_dir }}/{{ ansible_host }}/git" #nfsclient_server: "{{ global.nfs_server }}" -- name: ensure nfs volume is mounted - shell: mount -A - register: result - failed_when: result.rc != 0 and "Device busy" is not in result.stderr +- 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 state: restarted enabled: true + +- name: httpd password information + debug: + msg: | + Please provide a password using htpasswd, + in /htpasswd/cgit + when: cgit_authenticate diff --git a/roles/cgit/templates/cgit.httpd.conf.j2 b/roles/cgit/templates/cgit.httpd.conf.j2 deleted file mode 100644 index a8b4707..0000000 --- a/roles/cgit/templates/cgit.httpd.conf.j2 +++ /dev/null @@ -1,17 +0,0 @@ - -# httpd ~~ /etc/httpd.d/cgit.conf" -# managed by Ansible - -ext_ip="0.0.0.0" -server "cgit" { - listen on $ext_ip port {{ cgit_port }} - - # serve cgit static files directly: cgit.css and cgit.png - location "/cgit.*" { - root "/cgit" - no fastcgi - } - # cgit CGI - root "/cgi-bin/cgit.cgi" - fastcgi socket "/run/slowcgi.sock" -} diff --git a/roles/cgit/templates/cgitrc.j2 b/roles/cgit/templates/cgitrc.j2 deleted file mode 100644 index 5779255..0000000 --- a/roles/cgit/templates/cgitrc.j2 +++ /dev/null @@ -1,39 +0,0 @@ - -# cgit ~~ /var/www/conf/cgitrc -# managed by Ansible - -# visuals -css={{ cgit_config_css }} -logo={{ cgit_config_logo }} -favicon={{ cgit_config_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_config_root_desc }} -root-readme={{ cgit_config_root_readme }} - -# archives -snapshots=tar.gz - -# sections -section-from-path=1 -section-sort=1 -scan-path={{ cgit_git_dir_chroot }} diff --git a/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 b/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 new file mode 100644 index 0000000..6fb8e98 --- /dev/null +++ b/roles/cgit/templates/etc-httpd.d-cgit.conf.j2 @@ -0,0 +1,20 @@ + +# httpd ~~ /etc/httpd.d/cgit.conf" +# managed by Ansible + +ext_ip="0.0.0.0" +server "cgit" { + listen on $ext_ip port {{ cgit_port }} +{% if cgit_authenticate %} + authenticate "realm" with "/htpasswd/cgit" +{% endif %} + + # serve cgit static files directly: cgit.css and cgit.png + location "/cgit.*" { + root "/cgit" + no fastcgi + } + # cgit CGI + 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 new file mode 100644 index 0000000..8be36ce --- /dev/null +++ b/roles/cgit/templates/var-www-conf-cgitrc.j2 @@ -0,0 +1,39 @@ + +# 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 }} diff --git a/roles/cgit/vars/main.yml b/roles/cgit/vars/main.yml deleted file mode 100644 index aa2f526..0000000 --- a/roles/cgit/vars/main.yml +++ /dev/null @@ -1,17 +0,0 @@ - -# cgit ~~ roles/cgit/tasks/vars.yml -# default vars for cgit role - ---- - -cgit_user: "git" -cgit_group: "git" -cgit_git_dir: "/data/git" -cgit_git_dir_chroot: "/htdocs/cgit" -cgit_port: 1235 - -cgit_config_favicon: "http://rgoncalves.se/logo.png" -cgit_config_logo: "http://rgoncalves.se/logo.png" -cgit_config_css: "http://rgoncalves.se/style/cgit.css" -cgit_config_root_desc: "development hub" -cgit_config_root_readme: "http://rgoncalves.se" -- cgit v1.2.3