---

- name: copy initial ssh-key to destination host
  copy:
    content: "{{ services.gitolite.initialKey }}"
    dest: /var/lib/git/first-user-key.pub
    owner: git
    group: git

- name: Initial setup of gitolite
  become: yes
  become_user: git
  command:
    cmd: gitolite setup -pk /var/lib/git/first-user-key.pub
    creates: /var/lib/git/.gitolite

- name: Unlock the git user
  ignore_errors: yes
  command:
    cmd: passwd -u git

- name: fix gitolite.rc to set correct permissons
  patch:
    src: gitolite.rc.patch
    dest: /var/lib/git/.gitolite.rc

- name: set permissions for git dir
  file:
    path: /var/lib/git
    state: directory  
    mode: 0755
    owner: git
    group: git