summaryrefslogtreecommitdiff
path: root/roles/git-daemon
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-08-26 10:27:32 +0100
committerJoe Carstairs <me@joeac.net>2026-08-26 10:27:32 +0100
commit690f218cbdf89327408ea75f2d21fde257a29411 (patch)
treec0d695883f761afe8f1b0f0c90bdf73309cc1e5a /roles/git-daemon
parent9ec180130f0085340f3a6f2828b2f49d558a2548 (diff)
refactor git into cgit, git-daemon and git-http-backend
Diffstat (limited to 'roles/git-daemon')
-rw-r--r--roles/git-daemon/tasks/main.yml35
-rw-r--r--roles/git-daemon/templates/conf.d/git-daemon3
2 files changed, 38 insertions, 0 deletions
diff --git a/roles/git-daemon/tasks/main.yml b/roles/git-daemon/tasks/main.yml
new file mode 100644
index 0000000..5508b1e
--- /dev/null
+++ b/roles/git-daemon/tasks/main.yml
@@ -0,0 +1,35 @@
+- name: Install git daemon
+ community.general.apk:
+ name: git-daemon-openrc
+
+- name: Create read-only git user
+ ansible.builtin.user:
+ name: "{{ git_readonly_user }}"
+ group: "{{ git_readonly_group }}"
+
+- name: Configure git daemon
+ register: gitd_conf
+ ansible.builtin.template:
+ src: conf.d/git-daemon
+ dest: /etc/conf.d/git-daemon
+
+- name: Restart git daemon and configure to start on boot
+ when: gitd_conf is changed
+ ansible.builtin.service:
+ name: git-daemon
+ enabled: true
+ state: restarted
+
+- name: Start git daemon and configure to start on boot
+ when: not ( gitd_conf is changed )
+ ansible.builtin.service:
+ name: git-daemon
+ enabled: true
+ state: started
+
+- name: Mark git directory safe in system-wide git config
+ register: gitconfig
+ community.general.git_config:
+ name: safe.directory
+ add_mode: add
+ value: "{{ git_directory }}/*"
diff --git a/roles/git-daemon/templates/conf.d/git-daemon b/roles/git-daemon/templates/conf.d/git-daemon
new file mode 100644
index 0000000..8a757d1
--- /dev/null
+++ b/roles/git-daemon/templates/conf.d/git-daemon
@@ -0,0 +1,3 @@
+GITDAEMON_OPTS="--syslog --base-path={{ git_directory }}"
+GIT_USER="{{ git_readonly_user }}"
+GIT_GROUP="{{ git_readonly_group }}"