--- - 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: test if gitweb is already installed find: paths: /etc pattern: gitweb.conf register: check_installed - set_fact: install_gitweb: "{{ check_installed.matched == 0 }}" - name: install block when: install_gitweb 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: 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