File server¶
Salt uses the modular fileserver architecture. This feature added the ability for the Salt Master to integrate different file server backends. File server backends allow the Salt file server to act as a transparent bridge to external resources. A good example of this is the git backend, which allows Salt to serve files sourced from one or more git repositories, but there are several others as well. Click here for a full list of Salt’s fileserver backends.
File server backends¶
If fileserver_backend
is not defined in the Master config file, Salt will
use the roots backend, but the fileserver_backend option supports multiple
backends. When more than one backend is in use, the files from the enabled
backends are merged into a single virtual filesystem. When a file is
requested, the backends will be searched in order for that file, and the first
backend to match will be the one which returns the file.
fileserver_backend:
- roots
- git
With this configuration, the environments and files defined in the
file_roots
parameter will be searched first, and if the file is not found
then the git repositories defined in gitfs_remotes
will be searched.
GitFS file server backend¶
The gitfs backend allows Salt to serve files from git repositories. It can be enabled by adding git to the fileserver_backend list, and configuring one or more repositories in gitfs_remotes.
Note
If gitfs_provider is not configured, then Salt will prefer pygit2 if a suitable version is available, followed by GitPython and Dulwich.
Example configuration:
fileserver_backend:
...
- git
...
Lab: Using the GitFS Backend¶
apt-get install python-pygit2
Configure your master:
fileserver_backend:
- git
Specify one or more git://, https://, file://, or ssh:// URLs in gitfs_remotes to configure which repositories to cache and search for requested files:
gitfs_remotes:
- https://github.com/saltstack-formulas/openssh-formula.git
- https://github.com/saltstack-formulas/salt-formula.git
SSH remotes can also be configured using scp-like syntax:
gitfs_remotes:
- git@github.com:user/repo.git
- ssh://user@domain.tld/path/to/repo.git