summaryrefslogtreecommitdiff
path: root/roles/git/tasks/main.yml
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-08-25 22:40:31 +0100
committerJoe Carstairs <me@joeac.net>2026-08-25 22:40:31 +0100
commita697431cedc9bb005f38d209c18657db4f31a596 (patch)
tree470213f17ae6161a3c7f494027ebef9448932b4f /roles/git/tasks/main.yml
parent001a480ba1ea8327434873b59a00d8352c1a61c6 (diff)
serves git over https:// and git://
Diffstat (limited to 'roles/git/tasks/main.yml')
-rw-r--r--roles/git/tasks/main.yml77
1 files changed, 37 insertions, 40 deletions
diff --git a/roles/git/tasks/main.yml b/roles/git/tasks/main.yml
index 67083f7..033400e 100644
--- a/roles/git/tasks/main.yml
+++ b/roles/git/tasks/main.yml
@@ -11,32 +11,9 @@
ansible.builtin.group:
name: git
-- name: Add git user
+- name: Append 'git' group to nginx user
ansible.builtin.user:
- name: git
- group: git
-
-- name: Find existing shells
- register: existing_shells
- changed_when: false
- ansible.builtin.command: cat /etc/shells
-
-- name: Add git-shell to /etc/shells
- when: "'/git-shell' not in existing_shells.stdout"
- ansible.builtin.shell: which git-shell >> /etc/shells
-
-- name: Find current git login shell
- register: current_git_login_shell
- ansible.builtin.shell: "cat /etc/passwd | grep ^git: | grep -o [^:]*$"
-
-- name: Set git login shell to git-shell
- when: "'git-shell' not in current_git_login_shell"
- ansible.builtin.shell: chsh -s $(which git-shell) git
-
-- name: Create fcgiwrap user and append 'git' group
- ansible.builtin.user:
- name: "{{ fcgiwrap_user }}"
- group: "{{ fcgiwrap_group }}"
+ name: nginx
groups:
- git
append: true
@@ -45,21 +22,33 @@
ansible.builtin.file:
path: /media/seagate/git
state: directory
- owner: git
+ owner: nginx
group: git
mode: "750"
+- name: Set owners recursively in git directory in attached storage
+ ansible.builtin.file:
+ path: /media/seagate/git
+ state: directory
+ owner: nginx
+ group: git
+ recurse: true
+
- name: Symlink git directory to /srv/git
ansible.builtin.file:
src: /media/seagate/git
dest: /srv/git
- owner: git
+ owner: nginx
group: git
state: link
mode: "750"
- name: Configure fcgiwrap daemon
register: fcgiwrap_conf
+ vars:
+ fcgiwrap_socket: /run/fcgiwrap.sock
+ fcgiwrap_user: nginx
+ fcgiwrap_group: nginx
ansible.builtin.template:
src: conf.d/fcgiwrap
dest: /etc/conf.d/fcgiwrap
@@ -85,11 +74,21 @@
path: /etc/nginx/http.d/default.conf
state: absent
-- name: Install cgit nginx site config
+- name: Install htpasswd file
+ ansible.builtin.copy:
+ src: htpasswd
+ dest: /etc/nginx/.htpasswd
+ owner: nginx
+ group: nginx
+ mode: "400"
+
+- name: Install git.joeac.net nginx site config
register: cgit_nginx_site
+ vars:
+ fcgiwrap_socket: /run/fcgiwrap.sock
ansible.builtin.template:
- src: nginx/cgit.conf
- dest: /etc/nginx/http.d/cgit.conf
+ src: nginx/git.joeac.net.conf
+ dest: /etc/nginx/http.d/git.joeac.net.conf
owner: nginx
group: nginx
mode: "660"
@@ -134,24 +133,22 @@
name: gitd
group: git
-- name: Mark git directory safe for gitd git operations
- register: gitd_gitconfig
- ansible.builtin.copy:
- src: .gitconfig
- dest: ~gitd/.gitconfig
- owner: gitd
- group: git
- mode: "644"
+- name: Mark /srv/git/* safe in system-wide git config
+ register: gitconfig
+ community.general.git_config:
+ name: safe.directory
+ add_mode: add
+ value: /srv/git/*
- name: Restart git daemon and configure to start on boot
- when: gitd_conf is changed or gitd_gitconfig is changed
+ 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 or gitd_gitconfig is changed )
+ when: not ( gitd_conf is changed )
ansible.builtin.service:
name: git-daemon
enabled: true