Setup Git on FreeBSD


This article describes how to setup a git server on freebsd without authentification for private use


First we'll install the required packages via pkg install:

  - name: Installing (sta)git on "{{hostname}}"
      name: git,stagit
      state: present

This will also install a user for git and gitdaemon as well as corresponding groups.

Now, we'll create a directory under / where the git repositories will reside in the future.

  - name: create repos directory {{ git_base_dir }}
      path: "{{ git_base_dir }}"
      state: directory
      mode: '0755'
      recurse: yes
      owner: git
      group: git

For testing purposes and as a starting point for later maintenance (i.e. adding of new repositories), the following task creates a bare git repository.

  - name: git init --bare {{ project }}
    command: git init --bare {{ project }}
      chdir: "{{ git_base_dir }}"
    become_user: git

There is no service for git daemon installed, thus we're using inted to piggyback git daemon:

  - name: enable git-daemon as inetd service
      path: /etc/inetd.conf
      line: git stream tcp nowait git /usr/local/bin/git git daemon --inetd --verbose --export-all --reuseaddr --syslog --base-path=/repos --enable=receive-pack

As a last step, enable inted service during boot:

- name: enable inetd
    path: /etc/rc.conf
    line: inetd_enable="YES" 


git clone git://example.conf/ansible.git