Skip to content
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

Add pillar merging support #21

Open
doubletwist13 opened this issue May 3, 2018 · 2 comments
Open

Add pillar merging support #21

doubletwist13 opened this issue May 3, 2018 · 2 comments

Comments

@doubletwist13
Copy link

doubletwist13 commented May 3, 2018

The concept is simple but it's difficult for me to put into words so hopefully this all makes sense.

I have some server types that needs some extra packages that I don't want installed elsewhere but that don't necessarily need a whole role/formula defined for them. Everyone I talk to suggests that putting too much logic in a single init.sls pillar is not best practice, and that makes sense to me. It seems the best way to do this is leave the logic in top.sls like this:

#/srv/pillar/top.sls

base:  
  '*':  
    - packages 
  'srvtype*':  
    - packages.srvtype  

#/srv/pillar/packages/init.sls

packages:  
  pkgs:  
    wanted:  
      - bash  

#/srv/pillar/packages/srvtype.sls

packages:  
  pkgs:  
    wanted:  
      - otherpackage  

With this setup the 'srvtype*' minions only see 'otherpackage' as wanted as it overrides the packages in init.sls instead of merging.

I know it's possible to set salt master to always merge lists but I don't think that's the best way to go.

It would be fantastic if the formula could merge them, either by logic in the formula I guess, or by setting up the formula to get pillar data as a dictionary instead of lists? I know vaguely what is needed but don't have the chops to actually do it myself.

@javierbertoli
Copy link
Member

This seems to be a pillars issue, and not a formula issue, so I'm not sure if the formula (this or any other) is the correct place to add this logic you're mentioning.

Personally, I use pillarstack to manage these cases, where you can set a hierarchy of pillar files which will be read by some nodes and not others. It allows to merge values, ovewrite them, conditionally add parameters to some hosts, etc. It's quite powerful and I think it can allow you to do what you're mentioning (If I'm undertanding your use case correctly?)

@doubletwist13
Copy link
Author

Yes, I think that probably will do what I need. Thanks!

jleproust added a commit to opendatasoft/packages-formula that referenced this issue Nov 27, 2020
This can also be used as a workaround for the impossibility of merging
lists in the pillar
(saltstack-formulas#21).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants