Search code examples
salt-project

Using Gitfs as a backend doesn't seem to work?


I'm new to Salt and trying to set it up to pull from GitLab. I've been messing with the configuration for a few days and still can't get it to work.

I've got the following configuration for the master:

fileserver_backend:
  - gitfs

log_level: all

gitfs_base: main

gitfs_provider: pygit2

gitfs_remotes:
  - https://gitlab.com/grouphere/salt.git:
      - base: main
      - ref_types: branch
      - root: salt

ext_pillar:
  - git:
      - main https://gitlab.com/grouphere/salt.git:
          - root: pillar

My repository has only one branch main and has two folders, "pillar" and "salt". Inside the "salt" directory I have numerous folders, and a top.sls file (I've also tried putting the top.sls file in the root of the repository but that doesn't seem to make much difference.

When I run salt like so salt server1 pillar.items I correctly get back the pillar data. When I run salt-run fileserver.file_list I correctly get all of the contents of the /salt directory back.

When I try to run salt on the minion, however, I get that it couldn't find a top.sls file, despite it existing. Furthermore, when I check /var/cache/salt/gitfs, it has the repo map and a directory for the repo but it is empty — the /var/cache/salt/git_pillar directory has the content.

I've also tried to run salt-run fileserver.file_list saltenv=main to check if there is an environment issue but this returns nothing despite the environment being set to main in the master.conf

Does anyone know if this is an issue with my config, or an upstream issue? I'm using the onedir setup with version 3007.1.


Solution

  • you config looks correct. but from a minion run salt-call cp.list_master this will list the fileserver from the minions perspective.

    if that shows up correctly run salt-call state.show_top this should throw an error if salt://top.sls can't be found.

    as for the directory being empty. that is to be expected. the directory in gitfs is checked out as a bare git. if you use ls -a you should see the .git directory. but files won't show up there normally. the files are under cache_dir/files and cached directory listing is under cache_dir/file_lists

    other things to look into is the contents of your top file.