/var/log/salt/master
reports the following error:
[CRITICAL] Exception caught while initializing gitfs remote 'ssh://<user>@<server>:<port>/path/to/repo.git': Repository not found at /var/cache/salt/master/gitfs/<cache_id>/_
Traceback (most recent call last):
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 498, in __init__
self.new = self.init_remote()
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/gitfs.py", line 1920, in init_remote
self.repo = pygit2.Repository(self._cachedir)
File "/opt/saltstack/salt/extras-3.10/pygit2/repository.py", line 1606, in __init__
path_backend = init_file_backend(path, flags)
_pygit2.GitError: Repository not found at /var/cache/salt/master/gitfs/<cache_id>/_
[CRITICAL] Failed to load gitfs
[CRITICAL] Master failed pre flight checks, exiting
/var/cache/salt/master/gitfs/<cache_id>/_
and running the command git status
returns the following:
fatal: detected dubious ownership in repository at '<path to the repository>'
To add an exception for this directory, call:
git config --global --add safe.directory <path to the repository>
Salt master leveraging gitfs
Starting in git 2.35.2 users are prevented from executing git commands if the repository is owned by a different user
ls -l /var/cache/salt/master/gitfs/*/_/
/var/cache/salt/master/gitfs/*/_/.git
are owned by a different user than the salt-master is configured to run as update the ownership. For example, if the salt-master runs as the root user but /var/cache/salt/master/gitfs/*/_/.git
is owned by salt use the following command to correct the permissions:
chown root:root /var/cache/salt/master/gitfs/*/_/.git