When defining saltstack states, you are allowed to structure subdirectories, and within those subdirectories, one can create init.sls
files which carry the include
clause that points to other .sls
files. I am trying the same thing when defining the Pillar, and it seems that pillars don't look for init.sls files under the specified directories, nor they seem to care for the include
clause.
Here is an example:
#/srv/pillar/top.sls
base:
'*':
- dir1.dir2
- dir1.dir5
#/srv/pillar/dir1/dir2/init.sls
include:
- .users
- .passwords
/srv/pillar/dir1/dir2
has the following files
/srv/pillar/dir1/dir2/users.sls
/srv/pillar/dir1/dir2/passwords.sls
#/srv/pillar/dir1/dir5/init.sls
include:
- .addresses
- .names
/srv/pillar/dir1/dir5
has the following files
/srv/pillar/dir1/dir5/addresses.sls
/srv/pillar/dir1/dir5/names.sls
In this example, it may not be trivial about DRY - but when things become larger, it would be more ideal to have definitions that permit for include
instead now one would have to write the file as follows:
#/srv/pillar/top.sls
base:
'*':
- dir1.dir2.users
- dir1.dir2.passwords
- dir1.dir2.names
- dir1.dir5.addresses
Am I missing something - any suggestions on how to achieve what I'm reflecting on this use case?
This is because the pillar's top file is meant to accomplish this. Pillar was designed to provide key and value to a machine that is allowed to see it. It has no concept of including others.