3

I wonder if it is possible to include

jinja

from a pillar from salt-stack?

thanks

roeygol
  • 4,908
  • 9
  • 51
  • 88
roman
  • 607
  • 2
  • 10
  • 18

3 Answers3

3

Yes, you can use jinja in your pillar sls files.

https://docs.saltstack.com/en/latest/topics/pillar/

Utah_Dave
  • 4,531
  • 24
  • 23
3

Yes. Ensure that the file starts with the following on the first line.

#!jinja|yaml|gpg

This will ensure that all the pre-processors are executed, in this case jinja, yaml, and gpg decryption.

Pieter
  • 1,916
  • 17
  • 17
0

Consider this example

vi /srv/pillar/packages.sls

{% if grains['os'] == 'RedHat' %}
apache: httpd
git: git
{% elif grains['os'] == 'Debian' %}
apache: apache2
git: git-core
{% endif %}

company: Foo Industries

The above pillar sets two key/value pairs. If a minion is running RedHat, then the apache key is set to httpd and the git key is set to the value of git. If the minion is running Debian, those values are changed to apache2 and git-core respectively. All minions that have this pillar targeting to them via a top file will have the key of company with a value of Foo Industries.

Consequently this data can be used from within modules, renderers, State SLS files, and more via the shared pillar dictionary:

apache:
  pkg.installed:
    - name: {{ pillar['apache'] }}

Source: https://docs.saltproject.io/en/latest/topics/pillar/

Priyank
  • 341
  • 2
  • 11