salt icon indicating copy to clipboard operation
salt copied to clipboard

Feature request: `extend` functionality in pillar .sls

Open Zogg opened this issue 13 years ago • 81 comments

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.

Zogg avatar Mar 07 '13 22:03 Zogg

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

thatch45 avatar Mar 07 '13 22:03 thatch45

+1*10^3 :-)

inthecloud247 avatar Mar 25 '13 07:03 inthecloud247

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.

alexy avatar Mar 25 '13 18:03 alexy

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!

Mrten avatar Apr 05 '13 13:04 Mrten

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

eugenea avatar Apr 12 '13 20:04 eugenea

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.

ConsoleCatzirl avatar May 14 '13 19:05 ConsoleCatzirl

pillar of pillars :-)

inthecloud247 avatar May 14 '13 20:05 inthecloud247

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

awerner avatar Jun 05 '13 13:06 awerner

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

boltronics avatar Jun 21 '13 03:06 boltronics

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

thatch45 avatar Jun 21 '13 15:06 thatch45

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!

l2ol33rt avatar Jun 28 '13 17:06 l2ol33rt

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

johnnoone avatar Jul 08 '13 02:07 johnnoone

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

anitakrueger avatar Oct 02 '13 14:10 anitakrueger

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

luizsilva avatar Oct 08 '13 13:10 luizsilva

+1

eugenea avatar Oct 08 '13 18:10 eugenea

why don't use Jinja {%- include 'common.sls' -%} ?

redbaron avatar Oct 10 '13 18:10 redbaron

redbaron you can include without jinja. It will still not merge namespaces.

eugenea avatar Oct 10 '13 18:10 eugenea

+1 for Pillar files with some form of shared/extended namespaces.

davidjb avatar Oct 25 '13 00:10 davidjb

+1

kriberg avatar Oct 25 '13 06:10 kriberg

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.

garethgreenaway avatar Oct 31 '13 00:10 garethgreenaway