-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: extend
functionality in pillar .sls
#3991
Comments
This can get very complicated because pillar data is not structured like state data, but it should be a viable thing to add, I have set this to 0.15.0, but it might get bumped if it proves too complicated |
+1*10^3 :-) |
Default should be simple, and the current behavior -- overwrite -- is fine for the default. At least you can control it with the order of include's. Union will change arity of the data, which becomes problematic for nested structures. Let's define a uniform convention and have tests which will demonstrate each case. Then the tests can serve as the docs on include/extend behaviors. |
ran into this today, wanted to extend a network setting pillar with another one derived from the first and was puzzled why the data was missing. |
+1 Please make some way of mixing data structures. Otherwise it is impossible to manage complicated structures such as access lists without lots of CUT & PASTE. |
Another +1 here. I tend to use the top level pillar object name for scoping the pillar data and would like to be able to extend the object with more data from another pillar file. |
pillar of pillars :-) |
+1 from me, avoids tedious copying/maintenance of long lists (e.g. users) with only some different entries. |
+1. Forcing us to have unique IDs is making our state configuration messy and difficult to maintain. |
Yes, I am sorry we keep pushing this off, we will get it in! |
This seems to be a duplicate of an older issue I posted #2466. But I am still really looking forward to this being added in 17.0! |
I posted a proposal about include/extend issues on #2466. Eventually we can use the same logic for top files ? |
+1 forced to use unique id's is giving me a long complicated pillar dict for a server. and the state configuration now needs to look for different keys, where it could just loop through one if pillar dicts were extensible. |
+1 If pillars could have "defaults" then my life would be easier. |
+1 |
why don't use Jinja {%- include 'common.sls' -%} ? |
redbaron you can include without jinja. It will still not merge namespaces. |
+1 for Pillar files with some form of shared/extended namespaces. |
+1 |
To reiterate what I mentioned in the referenced issue above, what I'm looking to do by extending and replacing Pillar data is this: https://gist.github.com/garethgreenaway/7237050 I want common data available to all hosts but have the ability to overwrite those values on a host by host basis. |
Yes exactly, right now I have to do a bunch of copy-and-paste just to "override" one value. |
@garethgreenaway @axiom I'm doing something similar by using
This was the workaround I was able to create until we get a proper |
Oh, that's an interesting work-around, @ruimarinho. That'll definitely help me out until we get |
@ruimarinho |
+1 |
While you are waiting for this to be resolved, you can achieve the same effect (default.yaml, merged with lower down yaml) by setting This was detailed a bit earlier in the thread, but some extra details were missing (adding !aggregate to each leaf for example). Works like a charm. It solved the problem that many in this thread are looking for. Obviously there is no way to remove data, just change or append. Having to use !aggregate on each leaf is a problem for some yaml parsers. It would be nice for this to just be a native solution at some point similar to hiera with deep_merge. ie.. default.yaml
Then later in someother.yaml
|
The yamlex parser is not a good solution for this. I've tried to use it and it has its problems along with the fact that maintaining leaf level tags in the pillars sucks badly. I know the recurse_list merging strategy has been added to the dictupdate util. This will basically provide the features for deep_merging. Don't know if it will be in 2015.8.2 or in the next release though. |
I agree having to annotate every leaf is a pain and hard to track down problems if you forget. Again, for me this is a working solution until the proper one is deployed - I couldn't wait, and this request goes back to 2014 already. |
Functionality for "deep merge" of dictionaries is already implemented. At least, (1) the example in the initial post for this issue and (2) example of this SO question are essentially the same: So, in case of key-value dictionaries, the solution is in place by default at least since version Now, merging lists is completely different and less straightforward problem which:
Shouldn't this issue be closed? |
Similar problem exists when configured pillars Merging has to be consistent regardless of pillar data source (configuration or command line). |
+1 for a deep merge please! |
I am also missing list mergeing feature. My use case:
Now, if I want to deploy apache to some machines, I add
And I somehow expected that these two lists would merge. I guess I have to add dummy dicts:
Now |
@Talkless, I think you can rely solely on merging You already mentioned "dummy Input
OutputThe result will be:
ConvenienceIt is easily loopable
Is it suitable in your case? The majority of "merge The only exception is when order of items listed is important - see example here. I bet in such cases nobody wants to split lists across files and then merge them somehow in a less deterministic way (instead, it is much clearer to have a single file with one large single list - the problem of merging it does not exist in this case). |
Thank you @uvsmtid , it's nicer to use with values() . Good to know. |
+1 File2: (server specific) This way just ends up with the final pillar containing state3. This may be an odd way of using it but using the Pillars to set states gives me a lot more control for automating the configuration of this. |
Guys, the external pillar which provides this functionality is already included in 2016.3 release https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.stack.html ! |
Thanks @genuss! Will take a look at pillarstack. This could save tons of jinja effort :) |
Thanks @genuss. reading through the page it looks like it would do what i want.. although one thing I'm unsure about is the following line in the PillarStack Configuration Files section |
PillarStack (and reclass and suchlike) is absolutely overengineered when it comes to simple and intuitive application of pillar data aggregation in relation to merging lists. Using another complex module -- that also requires extra configuration -- just to butter over the lack of a basic future in the default pillar system is just a messy workaround. It's not a good solution. @uvsmtid 's suggestion to just use dicts is also just a hack because there are actually reasons to lay out data as a list. I.e. templating a list of values in some sort of config file
is just Just merging the list structures in the default pillar system appears to be the most simplest and only reasonable solution. |
@paul-mulvihill, I'm wondering if you could use salt:// paths that would allow PillarStack to read from git clone? I'd be interested to see the two working together. |
@mlalpho not sure how well that would work for the setup i am going for.. I'm intending to have the top.sls file become an automatically generated file as well down the line so given the pillarstack lives on the master that wouldn't work. I have a system of records that i'm aiming to create most of the pillar files and then potentially this one as the hierarchy expands. |
The salt/top.sls or pillar/top.sls ? From what I've read the PillarStack would have access to the pillar variable, so if you have some things defined in your git pillar, you can operate with them using jinja within PillarStack, which, is something you can't do with normal salt pillars at the moment without using jinja templating and loading yaml, json etc in to a jinja var. Aside from the merging of pillar data as a whole, that's already a big win in my opinion. |
I'm refering to the pillar top.sls. my setup is gitfs for everything with seperate repos for states and pillars. Eventually i'm goign to have our system of records generate the top.sls file for pillar information, |
By using PillarStack you do get nice merging strategies, but you lose out on being able to use them with other ext_pillar sources, like git_pillar or pillar_ldap. It would be nice if the merging strategies that PillarStack offers were part of the 'core' pillar code. |
:( guessed it would be something like that.. for the scale i'm building a salt estate I need git as the backend, so i'll have to find a work around until we can get this sort of features in the core code. |
You can have this very same feature using the slsutil.merge module. Here is a snippet to place in your map.jinja:
With that you'll have a full merged dict including lists. |
PillarStack author here: personally I'm also storing my pillar and states data in git (on bitbucket private repositories), and I'm using a docker container to automatically update my pillar and states tree when a new commit is pushed to bitbucket (new commits trigger POST web hook requests to my docker container which update the relevant pillar or states tree). Here is the docker container I'm using: |
Ran into this today. Would love to see this implemented at some point! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
AFAICT it's still broken, although not deterministically. Sometimes things are merged, sometimes replaced. There is no obvious pattern. |
Currently defining defining pillar key the second time will overwrite the contents of the first definition, i.e.:
The result pillar:
Proposition A
As the pillar definitions are pure data, there is no need to have unique IDs, or unique keys at all.
resulting pillar:
Proposition B
Pillar is data, data is a set. Implement basic set operations: union, intersection, difference for overlapping data definitions.
The text was updated successfully, but these errors were encountered: