diff --git a/roles/gitweb/tasks/main.yml b/roles/gitweb/tasks/main.yml index 5d71e81..a7407bc 100644 --- a/roles/gitweb/tasks/main.yml +++ b/roles/gitweb/tasks/main.yml @@ -10,16 +10,40 @@ - name: main block vars: - lighttpd_user: lighttpd - lighttpd_group: lighttpd + lighttpd_user: lighttpd + lighttpd_group: lighttpd http_port: 80 gitweb_user: gitweb gitweb_root: /home/gitweb/projects gitweb_stylesheet: custom_highlighting.css block: + - name: make hash of a random password + set_fact: + gitweb_pass: "{{ lookup('password', + '/dev/null length=15 chars=ascii_letters') + | password_hash('sha512') }}" + - name: add gitweb user user: name: "{{ gitweb_user }}" + password: "{{ gitweb_pass }}" + shell: /usr/bin/git-shell + + - name: create ssh directory + file: + state: directory + mode: 0700 + owner: "{{ gitweb_user }}" + path: "/home/{{ gitweb_user }}/.ssh" + + - name: copy ssh_pubkey for gitweb user + copy: + remote_src: yes + src: /root/.ssh/authorized_keys + dest: "/home/{{ gitweb_user }}/.ssh/authorized_keys" + owner: "{{ gitweb_user }}" + group: "{{ gitweb_user }}" + mode: 0600 - name: create project directory file: diff --git a/roles/gitweb/templates/lighttpd.conf.j2 b/roles/gitweb/templates/lighttpd.conf.j2 index d73f4f2..4d560f9 100644 --- a/roles/gitweb/templates/lighttpd.conf.j2 +++ b/roles/gitweb/templates/lighttpd.conf.j2 @@ -4,10 +4,10 @@ var.logdir = "/var/log/lighttpd" var.statedir = "/var/lib/lighttpd" server.modules = ( - "mod_redirect", - "mod_alias", - "mod_access", - "mod_accesslog", + "mod_redirect", + "mod_alias", + "mod_access", + "mod_accesslog", "mod_cgi", "mod_setenv" ) @@ -32,12 +32,12 @@ 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 - ) + setenv.add-environment = ( + "GITWEB_CONFIG" => "/etc/gitweb.conf", + "PATH" => env.PATH + ) - cgi.assign = ( ".cgi" => "" ) - server.indexfiles = ( "gitweb.cgi" ) + cgi.assign = ( ".cgi" => "" ) + server.indexfiles = ( "gitweb.cgi" ) }