3

I couldn't find anything in documentation about having multiple includes under the same key, but when I tried it, I ended up with only that last include keys under the root key.

For example:

/srv/pillar/top.sls

base:
  '*':
    - ports

cat /srv/pillar/ports/init.sls

include:
  - ports.frontend:
      key: ports
  - ports.backend:
      key: ports

/srv/pillar/ports/backend.sls

service1: 10000
service2: 10001

/srv/pillar/ports/frontend.sls

web1: 8000
web2: 8001

The result of salt '*' pillar.items devoid of other keys looks like this:

ports:
    ----------
    service1:
        10000
    service2:
        10001

Desired result would look like this:

ports:
    web1:
        8000
    web2:
        8001
    service1:
        10000
    service2:
        10001
LavaScornedOven
  • 253
  • 2
  • 10

1 Answers1

4

Here's the scheme I found that works for me.

It comes down to having intermediary file K that includes all sub-files S1...n, so when I include file K, I specify its key argument, having all sub-files under the specified key.

/srv/pillar/ports/backend.sls

service1: 10000
service2: 10001

/srv/pillar/ports/frontend.sls

web1: 8000
web2: 8001

/srv/pillar/ports/all_ports.sls

include:
  - ports.frontend
  - ports.backend

/srv/pillar/ports/init.sls

include:
  - ports.all_ports:
      key: ports

/srv/pillar/top.sls

base:
  '*':
    - ports

This will result in a pillar key ports looking like this:

ports:
  web1: 8000
  web2: 8001
  service1: 10000
  service2: 10001

UPDATE

I corrected inappropriate colons as suggested by marco.

LavaScornedOven
  • 253
  • 2
  • 10
  • Do you know how (did you try) to join these keys under top-level dictionary? In the example above, instead of accessing `pillar['ports']['web1']`, I would like to join `backend.sls` and `frontend.sls` pillars so that this key is a top-level one accessible through `pillar['web1']`. Thanks in advance. – uvsmtid Nov 22 '14 at 05:14
  • I've tried and combining keys in top-level dictionary also possible and works by merging key set (if there is no conflicting names). So, to avoid refocusing your answer, I posted it as an answer under more related issue [here](http://stackoverflow.com/a/27074516/441652). – uvsmtid Nov 22 '14 at 06:01