devconfig: add gitconfig /mirror/ sanity check
PATCH 1/1 devconfig: add gitconfig /mirror/ sanity check
When you leverage the use of /mirror/ say as an NFS server then your system will use a git service to allow guests with libvirt to connect to the NFS server through your own host. This works quite well, however git will prevent access if the directory is not owned by you.
To fix this the *host*, ie, localhost, must trust the directories, without this will fail on both the host and the guests:
/usr/bin/git ls-remote git://192.168.122.1/mirror/fstests.git -h refs/heads/HEAD
---
This heuristic only applies to when using /mirror/ but other folks might be interested in lifting this to other use cases if they have similar uses of NFS to share mirrored git trees. It took a while to debug this.
To be clear, this is needed on the *host*. Having it on the guest if fine but if you don't have it on the *host, then leveraging git over NFS won't work well and you can't expect the mirrored git tree to match the user if you are sharing a system with many users. And so this is needed if you are using git over NFS.
playbooks/roles/devconfig/tasks/main.yml | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
playbooks/roles/devconfig/tasks/main.yml +34 -0
@@ -41,6 +41,40 @@ # Distro agnostic stuff goes below +- name: Check if /mirror directory exists on localhost + delegate_to: localhost + stat: + path: /mirror + register: mirror_dir + run_once: true + +- name: Create an empty gitconfig if it doesn't exist on the localhost + delegate_to: localhost + file: + path: "{{ dev_gitconfig_src }}" + state: touch + mode: '0644' + when: + - mirror_dir.stat.exists + run_once: true + +- name: Check if any safe.directory entries exist + delegate_to: localhost + command: git config --global --get-all safe.directory + register: git_safe_dirs + failed_when: false + changed_when: false + run_once: true + when: mirror_dir.stat.exists + +- name: Add safe.directory = * if not already set + delegate_to: localhost + command: git config --global --add safe.directory '*' + when: + - mirror_dir.stat.exists + - "'*' not in git_safe_dirs.stdout_lines" + run_once: true + - name: Check if the developer has a git config delegate_to: localhost stat:
Signature · 1 line
2.47.2