Managing SALT configuration via git

From Jwiki


Configure Salt Master with Git

This guide demonstrates how to configure a Salt Master to use Git as the source of states, pillars, and reactors.

1. Create Salt Master Git Configuration

Create or edit the config:

/etc/salt/master.d/git.conf

fileserver_backend:
  - git


ext_pillar:
  - git:
      - main https://gitlab.com/tst-servers/ahsoka.git:
          - user: user
          - password: glpat-...
          - root: salts/pillar

gitfs_env_whitelist:
  - main

gitfs_provider: pygit2
gitfs_branch: main
gitfs_remotes:
  - https://gitlab.com/tst-servers/ahsoka:
      - user: user
      - password: glpat-...
      - root: salts/salt
      - name: salt
  - https://gitlab.com/tst-servers/ahsoka:
      - user: user
      - password: glpat-...
      - root: salts/reactor
      - name: reactor

2. Sync and Update Salt Data from Git

To apply the latest states and pillar data from Git, run:

salt-run fileserver.update
salt-run git_pillar.update

3. Apply States from the Main Branch

Apply all Salt states from the `main` environment:

salt '*' state.apply saltenv=main