You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support top_file_merging_strategy=same equivalent for pillar #28682
Corerelates to code central or existential to SaltFeaturenew functionality including changes to functionality and code refactors, etc.P2Priority 2PillarZRELEASED - 2017.7.0rc1
I have a similar use-case as what introduced top_file_merging_strategy=same (see #12483), and use it to ensure that only the top file of my current saltenv gets used. This allows me to keep identical topfiles in each environment, simply by using '{{ env }}:' instead of hardcoding the environment names in the topfiles. I can then easily merge my new topfiles into my base environment when testing is complete.
An ideal solution for me would be something like this:
Configuring the master with pillar_top_file_merging_strategy=same will make the master only use the topfile from the current saltenv. This should work in both state.highstate as well as pillar.items and friends.
The saltenv is passed to the template (currently, templates in the pillar always have saltenv set to 'base', which is both useless and confusing)
In addition to solving my problem, I believe this would also solve the use-cases described in #20506 as well as the one presented in the comments of #4389.
I agree it makes sense that the pillar facility matches the salt side. I use the much wanted top_file_merging_strategy=same option to stage my code deployments (salt + pillar files) but as pillar tops are merged, I end up with conflicting pillar files with merged values between QA and production for example.
Having the possibility to use the same setting for both sides would allow a simple workflow for continuous deployment pipelines.
I do not know if this feature is in the process of begin implemented, but I wonder what could be the impact of the pillarenv option on this.
If I understand correctly from the specifications given above, pillar_top_file_merging_strategy=same would allow to only use pillar data from the same env as specified by the saltenv option. This behavior would be equivalent to specify pillarenv=env, the later being more versatile as the env could be different as exemplified in #18808.
On the other hand, the pillarenv option looks more like a hack for now as it is not well documented (what does it do exactly, what is its purpose), and seems to be implemented on a feature-request basis and not where applicable: for instance, missing for pillar.items and saltmod.state, so it works if commands are run by hand but not if they are automated with orchestrate.
Both solutions I guess aim at allowing to version code and data.
So, do you see them as redondant or do they serve different purposes? Do you plan to implement them both? And more generally what is Saltstack vision on code and data versioning?
@ealphonse, I know of no immediate plans for pillarenv work, but I agree that it could be more robust than it currently is. Any ideas or code you can contribute to this effort would be very appreciated.
I like the pillar_top_file_merging_strategy=same better: it is an explicit configuration of how one uses Saltstack environments, rather than implicit, that is if you forget to set pillarenv somewhere, it is a bug.
I do not think that forcing pairing of the salt env and the pillar env is too limiting. I have a limited point of view based on my use-cases of course, but I never really could make a good use of merging environments, even though 100% of our processes are managed by Saltstack. More importantly, if you do use merging environments, you cannot version your top files, and versioning is a requirement in continuous deployment pipelines for example.
In details, I see environments as logical separations of processes: server life cycle, software maintenance, business processes, continuous deployment pipelines and their stages, etc. For each process, code and data are matched by their env name (the saltenv key as proposed above), never merged or mixed up.
For instance, I would not create pillar envs to specify different configurations for the same code / saltenv as described in #21359, but specify different entries in the same pillar dictionary: specify dynamic pillar data from the command line and use jinja to select the right entry, like pillar[dynamic_pillar_var]...
The same goes with the salt / code side: I prefer to simply use the filesystem hierachy, inside each env, to "merge" things by hand if needed.
So, actually, I do not know how to avoid merging issues between versions without an option like this. I would say both implementations will do, but pillar_top_file_merging_strategy=same seems simpler and more robust.
Probably not the help you were asking for, but what do you think?
It looks like the introduction of pillar_source_merging_strategy=none (introduced in 2016.3.4) may be a solution for my use-case. I'll update and/or close this issue when I have a chance to try it.
@knuta I interpreted "make the master only use the topfile from the current saltenv" to mean that you wanted the pillarenv to match the saltenv. Given that using pillarenv will only consider pillar data from the specified pillarenv, adding an option to pin pillarenv to saltenv seemed to match the use case.
If I understand correctly pillar_source_merging_strategy only concerns how you deal with merging two sources, either from the same environment or from different ones. You may still want pillar_source_merging_strategy=recurse and pillarenv_from_saltenv=True.
The doc is not clear about that, though. For instance, when you have these two files in the base env:
foo: 42
bar:
element1: True
---------------------------
bar:
element2: True
baz: quux
Does pillar_source_merging_strategy=none complain, overwrite?
As for the option, IMHO, pillarenv_from_saltenv=True fits well the case where you only use envs to version your code and data.
@ealphonse Seems easy enough to test. Given that we use a merge function in salt.utils.dictupdate to merge data, my educated guess is that you'd end up with:
Thank you for the clarification @terminalmage. And thank you for the option. It will be a great addition to orchestrate to implement data versionning with pillarenv_from_saltenv. I hope it will make it to the next release.
I'm going to close this since we haven't received a response from the submitter on this feature. If there are any concerns with the @terminalmage's explanation or code we can reopen this.
@meggiebot@terminalmage I think this issue should be re-opened. The pillarenv_from_saltenv option doesn't solve the problem, as far as I understand it.
If we're just talking about git pillars, the very confusing thing about all this is Salt can't make up its mind whether its the branch that determines the environment or whether it's the top file setting. Here's a simple example:
I have a 'master' branch which maps to the 'base' environment. This is applied to my production nodes.
I want to test a new pillar setting for 'base', so I create a new branch off of 'master' with those changes called "new-settings".
I push up these changes, and on a test minion I set "pillarenv" to "new-settings". I execute a "salt-call pillar.get ". Nothing returns. This is because I added the setting to 'base' in the pillar YAML, but the environment is now 'new-settings'. I have no choice now but to completely duplicate the 'base' YAML tree as a new tree 'new-settings'. This is extremely cumbersome and prone to error, no?
What would be better is if I could specify a pillar merging strategy just like top_file_merging_strategy that first applied 'base', and then tried to apply environment-specific settings. That, or have a separate setting that let's me specify that my pillar env is 'base', but my branch is 'new-settings'. (honestly, the latter is better, since it's more explicit about what's happening -- I don't really trust the merging behavior)
Am I missing something here? Is there some other way that people are doing this?
@jcmcken I believe that what you're looking for would involve setting the branch to __env__ as described here. Scroll down once you've clicked that link.
Corerelates to code central or existential to SaltFeaturenew functionality including changes to functionality and code refactors, etc.P2Priority 2PillarZRELEASED - 2017.7.0rc1
Activity
jfindlay commentedon Nov 10, 2015
@knuta, thanks for the well-researched issue. This is something I have wanted to do as well.
ealphonse commentedon May 12, 2016
I agree it makes sense that the pillar facility matches the salt side. I use the much wanted
top_file_merging_strategy=sameoption to stage my code deployments (salt + pillar files) but as pillar tops are merged, I end up with conflicting pillar files with merged values between QA and production for example.Having the possibility to use the
samesetting for both sides would allow a simple workflow for continuous deployment pipelines.Is this functionality planned?
ealphonse commentedon Jun 23, 2016
Hello @jfindlay , hello @knuta,
I do not know if this feature is in the process of begin implemented, but I wonder what could be the impact of the
pillarenvoption on this.If I understand correctly from the specifications given above,
pillar_top_file_merging_strategy=samewould allow to only use pillar data from the same env as specified by thesaltenvoption. This behavior would be equivalent to specifypillarenv=env, the later being more versatile as the env could be different as exemplified in #18808.On the other hand, the
pillarenvoption looks more like a hack for now as it is not well documented (what does it do exactly, what is its purpose), and seems to be implemented on a feature-request basis and not where applicable: for instance, missing forpillar.itemsandsaltmod.state, so it works if commands are run by hand but not if they are automated withorchestrate.Both solutions I guess aim at allowing to version code and data.
So, do you see them as redondant or do they serve different purposes? Do you plan to implement them both? And more generally what is Saltstack vision on code and data versioning?
Thank you in advance for your feedback,
Regards,
Erick
jfindlay commentedon Jun 23, 2016
@ealphonse, I know of no immediate plans for pillarenv work, but I agree that it could be more robust than it currently is. Any ideas or code you can contribute to this effort would be very appreciated.
ealphonse commentedon Jun 24, 2016
Thank you @jfindlay, I understand.
I like the
pillar_top_file_merging_strategy=samebetter: it is an explicit configuration of how one uses Saltstack environments, rather than implicit, that is if you forget to setpillarenvsomewhere, it is a bug.I do not think that forcing pairing of the salt env and the pillar env is too limiting. I have a limited point of view based on my use-cases of course, but I never really could make a good use of merging environments, even though 100% of our processes are managed by Saltstack. More importantly, if you do use merging environments, you cannot version your top files, and versioning is a requirement in continuous deployment pipelines for example.
In details, I see environments as logical separations of processes: server life cycle, software maintenance, business processes, continuous deployment pipelines and their stages, etc. For each process, code and data are matched by their env name (the
saltenvkey as proposed above), never merged or mixed up.For instance, I would not create pillar envs to specify different configurations for the same code / saltenv as described in #21359, but specify different entries in the same pillar dictionary: specify dynamic pillar data from the command line and use jinja to select the right entry, like
pillar[dynamic_pillar_var]...The same goes with the salt / code side: I prefer to simply use the filesystem hierachy, inside each env, to "merge" things by hand if needed.
So, actually, I do not know how to avoid merging issues between versions without an option like this. I would say both implementations will do, but
pillar_top_file_merging_strategy=sameseems simpler and more robust.Probably not the help you were asking for, but what do you think?
23 remaining items
knuta commentedon Jan 24, 2017
It looks like the introduction of
pillar_source_merging_strategy=none(introduced in 2016.3.4) may be a solution for my use-case. I'll update and/or close this issue when I have a chance to try it.terminalmage commentedon Jan 24, 2017
@knuta I interpreted "make the master only use the topfile from the current saltenv" to mean that you wanted the pillarenv to match the saltenv. Given that using
pillarenvwill only consider pillar data from the specified pillarenv, adding an option to pin pillarenv to saltenv seemed to match the use case.ealphonse commentedon Jan 24, 2017
If I understand correctly
pillar_source_merging_strategyonly concerns how you deal with merging two sources, either from the same environment or from different ones. You may still wantpillar_source_merging_strategy=recurseandpillarenv_from_saltenv=True.The doc is not clear about that, though. For instance, when you have these two files in the base env:
Does
pillar_source_merging_strategy=nonecomplain, overwrite?As for the option, IMHO,
pillarenv_from_saltenv=Truefits well the case where you only use envs to version your code and data.terminalmage commentedon Jan 24, 2017
@ealphonse Seems easy enough to test. Given that we use a merge function in salt.utils.dictupdate to merge data, my educated guess is that you'd end up with:
{ foo: 42 bar: { element1: True, element2: True }, baz: quux }ealphonse commentedon Jan 30, 2017
Thank you for the clarification @terminalmage. And thank you for the option. It will be a great addition to
orchestrateto implement data versionning withpillarenv_from_saltenv. I hope it will make it to the next release.meggiebot commentedon Feb 6, 2017
I'm going to close this since we haven't received a response from the submitter on this feature. If there are any concerns with the @terminalmage's explanation or code we can reopen this.
#38404 will be included in the Nitrogen release.
jcmcken commentedon Oct 31, 2017
@meggiebot @terminalmage I think this issue should be re-opened. The
pillarenv_from_saltenvoption doesn't solve the problem, as far as I understand it.If we're just talking about git pillars, the very confusing thing about all this is Salt can't make up its mind whether its the branch that determines the environment or whether it's the top file setting. Here's a simple example:
I have a 'master' branch which maps to the 'base' environment. This is applied to my production nodes.
I want to test a new pillar setting for 'base', so I create a new branch off of 'master' with those changes called "new-settings".
I push up these changes, and on a test minion I set "pillarenv" to "new-settings". I execute a "salt-call pillar.get ". Nothing returns. This is because I added the setting to 'base' in the pillar YAML, but the environment is now 'new-settings'. I have no choice now but to completely duplicate the 'base' YAML tree as a new tree 'new-settings'. This is extremely cumbersome and prone to error, no?
What would be better is if I could specify a pillar merging strategy just like top_file_merging_strategy that first applied 'base', and then tried to apply environment-specific settings. That, or have a separate setting that let's me specify that my pillar env is 'base', but my branch is 'new-settings'. (honestly, the latter is better, since it's more explicit about what's happening -- I don't really trust the merging behavior)
Am I missing something here? Is there some other way that people are doing this?
terminalmage commentedon Nov 2, 2017
@jcmcken I believe that what you're looking for would involve setting the branch to
__env__as described here. Scroll down once you've clicked that link.