diff options
| -rw-r--r-- | ansible.cfg | 6 | ||||
| -rw-r--r-- | roles/obsd_git/defaults/main.yml | 1 | ||||
| -rw-r--r-- | roles/obsd_git/tasks/main.yml | 24 | ||||
| -rw-r--r-- | roles/obsd_git/templates/gitconfig | 2 | ||||
| -rw-r--r-- | roles/obsd_git/templates/hooks/post-receive | 19 |
5 files changed, 52 insertions, 0 deletions
diff --git a/ansible.cfg b/ansible.cfg index aa38981..fb81ebc 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -6,3 +6,9 @@ interpreter_python = auto_silent [privilege_escalation] become = true become_method = doas + +[connection] +pipelining = true + +[doas_become_plugin] +allow_pipelining = true diff --git a/roles/obsd_git/defaults/main.yml b/roles/obsd_git/defaults/main.yml index 71abb53..e739c3d 100644 --- a/roles/obsd_git/defaults/main.yml +++ b/roles/obsd_git/defaults/main.yml @@ -3,3 +3,4 @@ obsd_git_home: /var/www/git obsd_git_domain: "{{ inventory_hostname }}" obsd_git_packages: - git +obsd_git_hooks_dir: "{{ obsd_git_home }}/hooks" diff --git a/roles/obsd_git/tasks/main.yml b/roles/obsd_git/tasks/main.yml index 59377fd..bf6abc8 100644 --- a/roles/obsd_git/tasks/main.yml +++ b/roles/obsd_git/tasks/main.yml @@ -75,3 +75,27 @@ owner: "{{ obsd_git_user }}" group: "{{ obsd_git_user }}" mode: "0755" + +- name: Create shared hooks directory + ansible.builtin.file: + path: "{{ obsd_git_hooks_dir }}" + state: directory + owner: "{{ obsd_git_user }}" + group: "{{ obsd_git_user }}" + mode: "0755" + +- name: Deploy post-receive hook + ansible.builtin.template: + src: hooks/post-receive + dest: "{{ obsd_git_hooks_dir }}/post-receive" + owner: "{{ obsd_git_user }}" + group: "{{ obsd_git_user }}" + mode: "0755" + +- name: Deploy git user gitconfig + ansible.builtin.template: + src: gitconfig + dest: "{{ obsd_git_home }}/.gitconfig" + owner: "{{ obsd_git_user }}" + group: "{{ obsd_git_user }}" + mode: "0644" diff --git a/roles/obsd_git/templates/gitconfig b/roles/obsd_git/templates/gitconfig new file mode 100644 index 0000000..078361d --- /dev/null +++ b/roles/obsd_git/templates/gitconfig @@ -0,0 +1,2 @@ +[core] + hooksPath = {{ obsd_git_hooks_dir }} diff --git a/roles/obsd_git/templates/hooks/post-receive b/roles/obsd_git/templates/hooks/post-receive new file mode 100644 index 0000000..34bfda4 --- /dev/null +++ b/roles/obsd_git/templates/hooks/post-receive @@ -0,0 +1,19 @@ +#!/bin/sh +set -o errexit +set -o nounset + +# $ man cgitrc +# ... +# agefile +# Specifies a path, relative to each repository path, which can be used +# to specify the date and time of the youngest commit in the +# repository. The first line in the file is used as input to the +# "parse_date" function in libgit. Recommended timestamp-format is +# "yyyy-mm-dd hh:mm:ss". You may want to generate this file from a +# post-receive hook. Default value: "info/web/last-modified". +agefile="$(git rev-parse --git-dir)"/info/web/last-modified +mkdir -p "$(dirname "$agefile")" && + git for-each-ref \ + --sort=-authordate --count=1 \ + --format='%(authordate:iso8601)' \ + >"$agefile" |