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') }}

Debugging Courier on Debian

I found Debugging authentication problems

I edited /etc/courier/authdaemonrc and added:

DEBUG_LOGIN=1

Then I created a mail.debug log file:

# touch /var/log/mail.debug
# chown syslog:adm /var/log/mail.debug

Then I created a mail.conf file for rsyslog in /etc/rsyslog.d/mail.conf:

mail.debug /var/log/mail.debug

Then I restarted the rsyslog service:

# service rsyslog restart

Now I have debug logs for mail services!

…oh, no, wait… I only have LOGIN debugging enabled.

Found this, edited /etc/courier/imapd-ssl and added:

IMAPDEBUGFILE=courier.log

Then restarted courier imapd-ssl:

# sudo /etc/init.d/courier-imap-ssl restart

Now there is a courier.log file in: /var/pcmail/jj5@progclub.org