I am relatively new to Salt, YAML, Jinja etc. Learning as I go. I have a yaml file being used with SaltStack to distribute several files to servers. A few of the files have a version indicator in the name. I would like to enter this once in the yaml file and then use it in name variables throughout the file. I’m not clear from searching if this is possible?
Example. I want to distribute a set of files to install DB2 version 11 fixpack 2. I have an install script, a configure script, a response file and a zip file with “fp2” in the name. I’d like to define a “ver” variable at the top of the yaml and then use it when defining the other filenames. Is this possible?
1 Answer
You can create a variable on the top of your state file using jinja format,
{% set variable_name = 'variable_value' %}
and then use {{ }} to render it like, {{ variable_name }}
Or if you want to use variable in a logic or within a loop,
{% if variable_name %}