Debugging JINJA in Salt Stack

So I was trying to figure out how to report the template source file within the template itself and I found myself wanting to know what was available in the JINJA globals for a Salt Stack JINJA template.

Turns out you use the show_full_context() function, like this:

Context is: {{ show_full_context() }}

You can parse the output to see what top-level items are available. In my case I found the ‘source’ setting for the JINJA template in use.

Hot tip: if you’re using Vim to inspect the show_full_context() output, try using ‘%’ or ‘]}’ to move between matching braces.

Bonus: while I was learning about reporting the JINJA context I discovered that you can call Salt functions from JINJA templates, like this:

# The following two function calls are equivalent.
{{ salt['cmd.run']('whoami') }}
{{ salt.cmd.run('whoami') }}

MediaWiki templates, revisited

After spending the afternoon investigating MediaWiki templates, I’ve decided that for the most part they are more trouble than they’re worth for any of my applications. I tried to create a ‘done’ template, that took username, user initials, date and ‘done note’ parameters, but really the code to call the template was just as long as not using the template, and the template broke when the ‘done note’ included a link that included an equals sign, which is just too shoddy. I’m giving up on templates until I find I actually have a use for them where the technology solves a problem that I actually have. At the moment that’s nothing.

MediaWiki templates

Today, after a long time, I am finally ready to learn about MediaWiki templates. After having put that off for weeks since I’d first heard of them, I found that it only took about five minutes to learn just about everything there is to know about them from the MediaWiki templates documentation. I think there are a few areas of the ProgClub wiki that could do with the use of templates, might go and see to that now.