The Anatomy of a Salt for VCF State File

The Anatomy of a Salt for VCF State File

The Anatomy of a Salt for VCF State File

Salt State File = A text file that tells the system which settings you want to check for.

File requirements:

  • Either YAML or JSON structure within body of text
  • Best practice is to append .sls to file name
  • Must follow the conventions and structure outlined below

Example Body of Text:

{% set compliance_config = "compliance_config" %}

{% from 'vcf_compliance_control_salt/conf/vcenter_ntp_dns.jinja' import global with context %}
{% set control_config = global[compliance_config] %}

{% set target_control_config = {"compliance_config": control_config} %}

vcenter_controls:
  vmware_compliance_control.check_control:
    - control_config: {{ target_control_config }}
    - product: "vcenter"

Breakdown of Sections

Here’s a breakdown of what’s happening, which sections you should modify and which portions you cannot:

Field Name File code example Explanation
Key-name-in-this-file

key-name-inside-both-files
{% set compliance_config = "compliance_config" %}
  • #{% set key-name-in-this-file = “key-name-inside-both-files” %}
  • Where key-name-in-this-file is a customer selected label to use as a set variable reference within this state file.
  • 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.
  • Link this Salt State file (containing the settings you want to target) and the Jinja file (containing the values of those settings) using this custom key you decide to use. This line is setting variable command in code.
  • You do not need to modify these labels if you want to use these labels.
  • Required field but default examples here can be used.
Path Location {% from 'vcf_compliance_control_salt/conf/vcenter.jinja' import global with context %}
  • Insert the path location where your jinja file is located.
  • Where “vcf_compliance_control_salt/conf/vcenter.jinja” where customer must fill in where they intend to store the referenced jinja file.
user-selected-label-for-holding-jinja-content {% set control_config = global[compliance_config] %}
  • #{% set user-selected-label-for-holding-jinja-content = global[key-name-inside-each-file] %}
  • Where user-selected-label-for-holding-jinja-content is a customer selected label for Salt to store the contents of the jinja file during processing.
  • The line above tells Salt to pull the contents of the Jinja file when processing this file. This line is setting variable command in code.
  • You do not need to modify these labels if you want to use these labels.
  • Required field but default examples here can be used.
Salt Logic Line {% set target_control_config = {"compliance_config": control_config} %}
  • You need this line for Salt to pull together the logic of both files.
  • Required fields that should use values from the key-name-in-this-file and user-selected-label-for-holding-jinja-content defined in this salt state file previously.
User-selected-label-for-settings

product-name
vcenter_controls:
vmware_compliance_control.check_control:
- control_config: {{ target_control_config }}
- product: "vcenter"
  • #user-selected-label-for-settings:
  • Where user-selected-label-for-settings is a customer selected label to identify and organize these collection settings.
  • # - product: "product-name"
  • Where product-name is a valid product as listed in the VCF Configuration ID’s under VMware Salt for VCF Component API Reference.