Skip to content

Instantly share code, notes, and snippets.

@thikade
Last active July 10, 2017 12:50
Show Gist options
  • Save thikade/effad5db76093a489661e2afa25c1d18 to your computer and use it in GitHub Desktop.
Save thikade/effad5db76093a489661e2afa25c1d18 to your computer and use it in GitHub Desktop.
Salt Jinja Hintsheet
  • Use pillar['foo'] for required options to fail if they are not present!
  • alias functions for better code
{%- set pget = salt['pillar.get'] %}
{%- set dget = salt['defaults.get'] %}
{%- set mget = salt['mine.get'] %}
{{ pget("foo1", "default1") }}
{{ pget("foo2", "default2") }}
{{ dget("foo3") }}
{{ dget("foo4") }}
  • examples
{% for user, uid in pillar.get('users', {}).items() %}
{{user}}:
  user.present:
    - uid: {{uid}}
{% endfor %}

Salt.states.test

https://docs.saltstack.com/en/latest/ref/states/all/salt.states.test.html

Masterless Minions

https://docs.saltstack.com/en/latest/topics/tutorials/quickstart.html
https://docs.saltstack.com/en/latest/topics/tutorials/standalone_minion.html

Jinja2 Hintsheet

http://jinja.pocoo.org/docs/2.9/templates/#builtin-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment