openqa: improve how we do the git config thing

The background to this is
https://bugzilla.redhat.com/show_bug.cgi?id=2073414 , in response
to which git was changed to die if a user runs git commands
on a repo which it doesn't own. In openQA, the test directory
is a git repo and openQA itself likes to run git commands on it,
but this is often going to be as a different user than the owner
of the directory. In fact on the worker hosts, the user that owns
the directory (geekotest on the server box) doesn't even exist.

This just sets the config by copying a file in place rather than
running a git command (which is hard to get to be idempotent) and
uses `/etc/gitconfig` so we don't wind up with a file in the
_openqa-worker user's home directory, which is meant to be empty.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2022-05-27 10:20:29 -07:00
parent 3d148f5e7f
commit bf4f704096
2 changed files with 3 additions and 4 deletions

View file

@ -0,0 +1,2 @@
[safe]
directory = /var/lib/openqa/share/tests/fedora

View file

@ -171,10 +171,7 @@
when: openqa_tap|bool
- name: Tell git it's OK for _openqa-worker to run 'git' on the test dir
command: git config --global --add safe.directory /var/lib/openqa/share/tests/fedora
become: yes
become_user: _openqa-worker
when: openqa_nfs_worker|bool
copy: src=gitconfig dest=/etc/gitconfig owner=root group=root mode=0644
# this is kinda lazy - we could have a separate openqa_swtpm var so we
# we could potentially separate tap worker hosts from swtpm ones - but