Skip to content

Commit cd720a5

Browse files
committed
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 Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 2b61c99 commit cd720a5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

playbooks/roles/devconfig/tasks/main.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,40 @@
4141

4242
# Distro agnostic stuff goes below
4343

44+
- name: Check if /mirror directory exists on localhost
45+
delegate_to: localhost
46+
stat:
47+
path: /mirror
48+
register: mirror_dir
49+
run_once: true
50+
51+
- name: Create an empty gitconfig if it doesn't exist on the localhost
52+
delegate_to: localhost
53+
file:
54+
path: "{{ dev_gitconfig_src }}"
55+
state: touch
56+
mode: '0644'
57+
when:
58+
- mirror_dir.stat.exists
59+
run_once: true
60+
61+
- name: Check if any safe.directory entries exist
62+
delegate_to: localhost
63+
command: git config --global --get-all safe.directory
64+
register: git_safe_dirs
65+
failed_when: false
66+
changed_when: false
67+
run_once: true
68+
when: mirror_dir.stat.exists
69+
70+
- name: Add safe.directory = * if not already set
71+
delegate_to: localhost
72+
command: git config --global --add safe.directory '*'
73+
when:
74+
- mirror_dir.stat.exists
75+
- "'*' not in git_safe_dirs.stdout_lines"
76+
run_once: true
77+
4478
- name: Check if the developer has a git config
4579
delegate_to: localhost
4680
stat:

0 commit comments

Comments
 (0)