Per-saltenv gitfs configuration parameters
Hi,
I am trying to setup multiple environments (base, dev, prod) all getting their files from a git repository. I would like to be able to specify a root directory (or a branch) for each environment similar to ext_pillar. but in gitfs_remotes there seems to be no such option. for example:
gitfs_remotes:
- gitrepo:
- root: base (# base directory in the repo contains base sls files)
- env: base (# this option currently does not exists!)
- gitrepo: ( #same repo above or can be another repo)
- root: dev (# dev directory in the repo containing dev sls files)
- env: dev (# branch or directory)
you get the idea.
There is only an option gitfs_base that allow me to specify which branch maps to the base environment. I would like to similarly map dev and prod to branches or directories.
One benefit of such structure is using the same state files to do different things in different environment such as managing different files:
manage_yum.sls
/etc/yum.conf
- file.managed:
- source: salt://files/yum.conf
repo structure:
/
base/
manage_yum.sls
files/
yum.conf
dev/
manage_yum.sls
files/
yum.conf
will copy different files based on the env its in.
@aabognah - thanks for the report. Not sure if this is a bug or a feature/enhancement. I'm sure others will comment.
@terminalmage Any insight on this one?
Gitfs maps branches and tags as environments. Is there something specific that is stopping you from simply putting the desired files in the same location in each environment?
There is currently no mechanism to do what you're asking. The reason for this is that gitfs works differently from git_pillar. In git_pillar you only specify a single branch/environment at a time, where a single gitfs remote will provide all branches/tags as environments.
The most elegant solution would be to add the ability to specify per-environment configuration parameters within the per-remote params, something like this:
gitfs_remotes:
- https://foo.com/bar.git:
- base: foo
- per_saltenv_config:
- base:
- root: base
- dev:
- root: dev
This would be a feature add.
I've renamed this issue to more accurately describe the feature which was requested.
ZD-714
This is implemented in https://github.com/saltstack/salt/pull/33650 and is targeted for the next feature release of Salt.
See here for a usage example. Once the pull request is merged, this documentation will be available on the development branch's docs (located here), but as this PR is yet to be merged, there is no live documentation for this feature yet.
Thanks @terminalmage . Sorry for not replying earlier but I had given up on the multi-environment setup after struggling with many issues. I might give it a try now after the updates.
@aabognah no problem, if you notice any problems, please file a new issue and mention me in the issue so that I am alerted to it.