The configuration to integrate Git into the Salt master file system looks something like the following example
gitfs_remotes:
- https://<REPO_SERVER>/<ORG>/<REPO>.git:
- username: <GIT_USER>
- password: <GIT_TOKEN>
Users not able to see the list of files provided from Git when running commands like the following:
salt-call cp.list_states
SaltProject - all versions
Aria Config - all versions
VMware Salt - all versions
The configuration is incomplete.
The configuration is missing the mapping of Salt env to the branch in the Git repo. Salt provides a default env known as "base". Most Git repositories use "main" or "master" as the default branch for all updates.
To resolve this issue, the user must add a configuration section like the following:
gitfs_remotes:
- https://<REPO_SERVER>/<ORG>/<REPO>.git:
- username: <GIT_USER>
- password: <GIT_TOKEN>
- saltenv:
- base:
- ref: main
By adding the "saltenv" section we are telling the Salt master that any requests for files in the default "base" environment check the "main" branch of the repository for any matches. We can add as many environments as are necessary. For example, I might use a "devel" branch to develop and test my code before promoting it to production in the "main" branch. To get the Salt master to see the new branch I would need to update the Salt master with the following additional configuration.
gitfs_remotes:
- https://<REPO_SERVER>/<ORG>/<REPO>.git:
- username: <GIT_USER>
- password: <GIT_TOKEN>
- saltenv:
- base:
- ref: main
- devel: # This is the name that Salt will use as the environment
- ref: devel # This is the name of the branch created in the repository. The two do not have to match.
Once the configuration is updated on the Salt master with the correct mapping, you will need to
Additional GitFS configuration information can be found at SaltProject here:
https://docs.saltproject.io/en/3006/ref/states/top.html
https://docs.saltproject.io/en/3006/topics/tutorials/gitfs.html