Search code examples
salt-projectvagrant-provision

Saltstack: Is there any way to templatize top.sls file?


I'm working currently on Saltstack and I didn't find my answer on the documentation nor the examples.

So I just wonder if it is possible to templatize top.sls file, aka highstate file with some Jinja2 templating?

For instance, I would apply a state on a machine depending on some values in the pillar that I provide in vagrant using the salt provisioner. I tried and it looks like it doesn't work, the jinja in the topfile looks like it's not been rendered.

Is there a way using the match keyword for example?


Solution

  • In top.sls, you can use Jinja. We use it, for example, to retrieve pillar values with salt['pillar.get'] and include different states depending of those pillar.