Skip to content

Feature request: extend functionality in pillar .sls #3991

Closed

Description

@Zogg

Currently defining defining pillar key the second time will overwrite the contents of the first definition, i.e.:

first.sls:
data:
  love

second.sls:
data:
  hate

top.sls:
base:
 "*":
   - first
   - second

The result pillar:

data:
  hate

Proposition A

As the pillar definitions are pure data, there is no need to have unique IDs, or unique keys at all.

  • If there are overlapping keys defined, merge their contents by default:
first.sls:
data:
  love

second.sls:
data:
  hate

resulting pillar:

data:
  love
  hate
  • Have keyword reserved to override default behavior and have second definition replace the first one
  • Have keyword reserved to have a second definition exclude data from the first one

Proposition B

Pillar is data, data is a set. Implement basic set operations: union, intersection, difference for overlapping data definitions.

Activity

  1. thatch45 commented on Mar 7, 2013

    @thatch45
    Contributor

    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

  2. inthecloud247 commented on Mar 25, 2013

    @inthecloud247
    Contributor

    +1*10^3 :-)

  3. alexy commented on Mar 25, 2013

    @alexy

    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.

  4. Mrten commented on Apr 5, 2013

    @Mrten
    Contributor

    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 from me!

  5. eugenea commented on Apr 12, 2013

    @eugenea

    +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.

  6. ConsoleCatzirl commented on May 14, 2013

    @ConsoleCatzirl
    Contributor

    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.

  7. inthecloud247 commented on May 14, 2013

    @inthecloud247
    Contributor

    pillar of pillars :-)

  8. awerner commented on Jun 5, 2013

    @awerner
    Contributor

    +1 from me, avoids tedious copying/maintenance of long lists (e.g. users) with only some different entries.

  9. boltronics commented on Jun 21, 2013

    @boltronics
    Contributor

    +1. Forcing us to have unique IDs is making our state configuration messy and difficult to maintain.

  10. thatch45 commented on Jun 21, 2013

    @thatch45
    Contributor

    Yes, I am sorry we keep pushing this off, we will get it in!

  11. l2ol33rt commented on Jun 28, 2013

    @l2ol33rt
    Contributor

    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!

  12. johnnoone commented on Jul 8, 2013

    @johnnoone
    Contributor

    I posted a proposal about include/extend issues on #2466. Eventually we can use the same logic for top files ?

  13. anitakrueger commented on Oct 2, 2013

    @anitakrueger
    Contributor

    +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.

  14. luizsilva commented on Oct 8, 2013

    @luizsilva

    +1 If pillars could have "defaults" then my life would be easier.

  15. 62 remaining items

  16. paul-mulvihill commented on Jun 15, 2016

    @paul-mulvihill

    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
    "The path of these yaml files must be relative to the directory of the PillarStack config file."
    This would imply that it only works if the pillar yaml files are locally on the salt master with the pillarstack config file?
    I'm using the gitfs option to share my state/pillar files accross multiple masters. Any one have PillarStack working with gitfs? or know that it definitely is possible?

  17. mlalpho commented on Jun 16, 2016

    @mlalpho
    Contributor

    @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.

  18. paul-mulvihill commented on Jun 17, 2016

    @paul-mulvihill

    @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.

  19. mlalpho commented on Jun 17, 2016

    @mlalpho
    Contributor

    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.

  20. paul-mulvihill commented on Jun 17, 2016

    @paul-mulvihill

    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,
    In my setup the state\top.sls reads the "appliedstate" grain I define and uses it's values to apply states.
    I want to avoid any key configuration being installed on the masters except for telling them to look at gitfs. I'd rather changes to the pillar hierarchy or values are purely within the repo.

  21. mrichar1 commented on Jul 5, 2016

    @mrichar1
    Contributor

    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.

  22. paul-mulvihill commented on Jul 5, 2016

    @paul-mulvihill

    :( 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.

  23. danlsgiga commented on Jul 5, 2016

    @danlsgiga
    Contributor

    You can have this very same feature using the slsutil.merge module. Here is a snippet to place in your map.jinja:

    # vim: sts=2 ts=2 sw=2 et ai
    
    {# Start with defaults from defaults.yml #}
    {%- import_yaml 'nginx/proxy/web/defaults.yml' as default_settings %}
    
    {# Only add key:values here that differ from whats in defaults.yml #}
    {%- set os_map = salt['grains.filter_by']({
           'Debian': {},
           'RedHat': {
             'pkg': {
               'name': [
                   'nginx',
                ],
             },
             'service': {
               'name': 'nginx',
               'state': 'running',
               'enable': True,
             },
             'user': 'nginx',
             'group': 'nginx',
             'conf': '/etc/nginx/nginx.conf',
             'confd_dir': '/etc/nginx/conf.d',
             'certs_dir': '/etc/nginx/conf.d/certs',
             'vhosts_dir': '/etc/nginx/conf.d/vhosts',
             'docroot': '/usr/share/nginx/html',
             'pool': salt['grains.get']('pool', 'default'),
           },
         },
         grain="os_family"
       )
    %}
    
    {# Merge the os_map and the pillar data to the default_settings #}
    {%- set nginx = salt['slsutil.merge'](
                      salt['slsutil.merge'](
                          os_map,
                          default_settings.nginx.proxy.web,
                          merge_lists=True
                        ),
                        salt['pillar.get'](
                          'nginx:proxy:web', {}
                        ),
                        merge_lists=True
                    )
    %}
    

    With that you'll have a full merged dict including lists.

  24. bbinet commented on Jul 5, 2016

    @bbinet
    Contributor

    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:
    https://github.com/bbinet/docker-hooked-git-workdir

  25. sdemura commented on Nov 11, 2016

    @sdemura

    Ran into this today. Would love to see this implemented at some point!

  26. stale commented on Jul 24, 2018

    @stale

    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.

  27. hramrach commented on Jul 23, 2024

    @hramrach

    AFAICT it's still broken, although not deterministically.

    Sometimes things are merged, sometimes replaced. There is no obvious pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreFeatureP1Pillarstale

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions