From 905db417d24510dbc7acd35a275e11fedc44c9cc Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sun, 2 May 2021 14:41:00 -0400 Subject: [PATCH] add gitweb role --- all.yml | 5 ++ roles/baikal/tasks/main.yml | 0 roles/gitweb/tasks/main.yml | 50 +++++++++++++++++++ .../templates/custom_highlighting.css.j2 | 23 +++++++++ roles/gitweb/templates/gitweb.conf.j2 | 15 ++++++ roles/gitweb/templates/lighttpd.conf.j2 | 43 ++++++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 roles/baikal/tasks/main.yml create mode 100644 roles/gitweb/tasks/main.yml create mode 100644 roles/gitweb/templates/custom_highlighting.css.j2 create mode 100644 roles/gitweb/templates/gitweb.conf.j2 create mode 100644 roles/gitweb/templates/lighttpd.conf.j2 diff --git a/all.yml b/all.yml index 64b5825..73052c3 100644 --- a/all.yml +++ b/all.yml @@ -24,3 +24,8 @@ - hosts: gallery tags: containers, gallery roles: [flask] + +- hosts: gitweb + tags: containers, gitweb + roles: [gitweb] + diff --git a/roles/baikal/tasks/main.yml b/roles/baikal/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/roles/gitweb/tasks/main.yml b/roles/gitweb/tasks/main.yml new file mode 100644 index 0000000..5d71e81 --- /dev/null +++ b/roles/gitweb/tasks/main.yml @@ -0,0 +1,50 @@ +--- +- name: install packages + apk: + name: + - lighttpd + - git-gitweb + - highlight + - perl-cgi + state: present + +- name: main block + vars: + lighttpd_user: lighttpd + lighttpd_group: lighttpd + http_port: 80 + gitweb_user: gitweb + gitweb_root: /home/gitweb/projects + gitweb_stylesheet: custom_highlighting.css + block: + - name: add gitweb user + user: + name: "{{ gitweb_user }}" + + - name: create project directory + file: + path: "{{ gitweb_root }}" + state: directory + owner: "{{ gitweb_user }}" + + - name: install lighttpd template + template: + src: lighttpd.conf.j2 + dest: /etc/lighttpd/lighttpd.conf + + - name: install gitweb template + template: + src: gitweb.conf.j2 + dest: /etc/gitweb.conf + + - name: install gitweb stylesheet + template: + src: "{{ gitweb_stylesheet }}.j2" + dest: "/usr/share/gitweb/static/{{ gitweb_stylesheet }}" + +- name: enable and (re)start lighttpd + service: + name: lighttpd + enabled: yes + state: restarted + diff --git a/roles/gitweb/templates/custom_highlighting.css.j2 b/roles/gitweb/templates/custom_highlighting.css.j2 new file mode 100644 index 0000000..20564af --- /dev/null +++ b/roles/gitweb/templates/custom_highlighting.css.j2 @@ -0,0 +1,23 @@ +.pre { + background-color: #333; + color: #eee; +} + + +/* Style definition file generated by highlight 3.52, http://www.andre-simon.de/ */ +/* highlight theme: vim zenburn */ +.num { color:#dca3a3; font-weight:bold; } +.esc { color:#dca3a3; font-weight:bold; } +.str { color:#cc9393; } +.pps { color:#cc9393; } +.slc { color:#7f9f7f; font-style:italic; } +.com { color:#7f9f7f; font-style:italic; } +.ppc { color:#ffcfaf; font-weight:bold; } +.opt { color:#dcdccc; } +.ipl { color:#c07abe; } +.lin { color:#9fafaf; } +.kwa { color:#e3ceab; } +.kwb { color:#dfdfbf; font-weight:bold; } +.kwc { color:#aae3b2; } +.kwd { color:#aabfe3; } + diff --git a/roles/gitweb/templates/gitweb.conf.j2 b/roles/gitweb/templates/gitweb.conf.j2 new file mode 100644 index 0000000..9c682d7 --- /dev/null +++ b/roles/gitweb/templates/gitweb.conf.j2 @@ -0,0 +1,15 @@ + +# The directories where your projects are. Must not end with a slash. +$projectroot = "{{gitweb_root}}"; + +# Base URLs for links displayed in the web interface. +#@git_base_url_list = qw(git://{{ansible_host}} http://{{ansible_host}}); + +# syntax highlighting +#$highlight_bin = "/usr/bin/highlight"; +$feature{'highlight'}{'default'} = [1]; + +$site_name = 'git'; + +push @stylesheets, "static/{{gitweb_stylesheet}}"; + diff --git a/roles/gitweb/templates/lighttpd.conf.j2 b/roles/gitweb/templates/lighttpd.conf.j2 new file mode 100644 index 0000000..d73f4f2 --- /dev/null +++ b/roles/gitweb/templates/lighttpd.conf.j2 @@ -0,0 +1,43 @@ + +var.basedir = "/var/www/localhost" +var.logdir = "/var/log/lighttpd" +var.statedir = "/var/lib/lighttpd" + +server.modules = ( + "mod_redirect", + "mod_alias", + "mod_access", + "mod_accesslog", + "mod_cgi", + "mod_setenv" +) + +server.port = "{{ http_port }}" +server.username = "{{ lighttpd_user }}" +server.groupname = "{{ lighttpd_group }}" +server.document-root = var.basedir + "/htdocs" +server.pid-file = "/run/lighttpd.pid" +server.errorlog = var.logdir + "/error.log" +server.follow-symlink = "disable" +accesslog.filename = var.logdir + "/access.log" +dir-listing.activate = "enable" +url.access-deny = ("~", ".inc") + +# +# gitweb +# + +include "mime-types.conf" + +url.redirect += ( "^/gitweb$" => "/gitweb/" ) +alias.url += ( "/gitweb" => "/usr/share/gitweb/" ) +$HTTP["url"] =~ "^/gitweb/" { + setenv.add-environment = ( + "GITWEB_CONFIG" => "/etc/gitweb.conf", + "PATH" => env.PATH + ) + + cgi.assign = ( ".cgi" => "" ) + server.indexfiles = ( "gitweb.cgi" ) +} +