user190270
user190270

Reputation: 15

saltstack pillar does not follow the norm of using init.sls with include statements

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?

Upvotes: 0

Views: 644

Answers (2)

Andi
Andi

Reputation: 1287

I think what you describe is possible. As described in SaltStack Docu you can include pillars in other pillars. And also a init.sls (see Pillar Walkthrough) is possible. So I do not see why you should'n do it exactly how you described it. In fact i just did it in the same way and it works!

Upvotes: 1

RogueOverride
RogueOverride

Reputation: 112

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.

Upvotes: 0

Related Questions