The Anatomy of a Salt for VCF Jinja File

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:
  • #key-name-inside-both-files:
  • Where key-name-inside-both-files is a customer selected label to use as a set variable that is used in both a state file and a matching Jinja file.
  • This is the same key custom key you will use in both the Salt state file and the jinja file for consistency.
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"
  • #configuration_id: "configuration_id"
  • Where configuration_id is the exact ID of the configuration setting that is being targeted.
  • #configuration_title: "configuration_title"
  • Where configuration_title is the exact title of the configuration setting that is being targeted.
  • The structure of this stanza must be retained when referencing the configuration setting ID to be used. The Configuration ID variable and Title must match what is listed in VCF Configuration ID’s under VMware Salt for VCF Component API Reference.
  • Please note that the lines below the Configuration ID and Title are specific to each setting and you must have the correct format.
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"
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.