The Anatomy of a Salt for VCF Jinja File
The Anatomy of a Salt for VCF Jinja File
Salt Jinja File = A text file that tells the system what values you want to use in conjunction with a Salt for VCF State File that contains the selected settings.
File requirements:
- Either YAML or JSON structure within body of text
- Best practice is to append .jinja to file name
- Must follow the conventions and structure outlined below
- A Jinja file can be used by any Salt State file but a Salt State File does not necessarily need a Jinja file. In other words, you do not need a Jinja file to run a Salt state. At this time, we are outlining best practices where both a Salt State File and a Jinja File are used consistently.
Example body of text for a jinja file:
{% load_yaml as global %}
compliance_config:
vcenter:
ntp:
metadata:
configuration_id: "1246"
configuration_title: "Synchronize system clocks to a universal time source for all devices to automatically synchronize."
value:
mode: "NTP"
servers:
- "10.0.0.250"
dns:
metadata:
configuration_id: "1271"
configuration_title: "For systems using DNS resolution, at least two name servers must be configured."
value:
mode: "is_static"
servers:
- "10.0.0.250"
- "10.0.0.251"
{% endload %}
Mapping Breakdown
Here’s the mapping of what you need and what you need to change:
| Code snippet | Explanation |
|---|---|
{% load_yaml as global %} |
Keep this if you are using YAML in the body of the Jinja file so Salt will parse the content correctly. |
compliance_config: |
|
vcenter: |
|
dns: |
Example of second stanza in the same Jinja file containing the values of a second setting. |
{% endload %} |
Required for Salt to process Jinja file properly. |