I'm writing a lot of Salt states and I want to use the do tag extension as suggested in this StackOverflow answer.
According to the Salt docs, I should be able to edit /etc/salt/master
to add these lines:
jinja_env:
extensions: ['jinja2.ext.do']
jinja_sls_env:
extensions: ['jinja2.ext.do']
and then restart the salt-master
service and have access to the do
tag. However, I tried that and I get the same error as before, so it's not recognizing the tag.
I've confirmed that the extension is available on the server by testing it at the command line:
>>> import jinja2
>>> jinja2.Environment(extensions=['jinja2.ext.do']).parse(open('/path/to/mytemplate.jinja').read())
Template(body=[...])
What am I missing? How do I configure Salt to use the {% do %}
Jinja tag?
From reviewing the Salt source code, it appears that it applies these extensions automatically if they're available. The error I was getting about the template failing to render appears to be from an unrelated syntax error.
So the true answer all along is that you don't have to do anything to make use of the {% do %}
template tag.