Excerpts from Junichi Nomura's message of 2014-10-30 14:51 +10:00:
Hi,
In beaker 0.18, "rhts_post" snippet has a following construct:
if [ -f /etc/sysconfig/readahead ] ; then {% snippet 'readahead_sysconfig' %} fi
This is error-prone because if we have site-local "readahead_sysconfig" snippet, which is empty, generated shell script will be broken. (Actually, I've been using empty "readahead_sysconfig" snippet)
So it might be better to move if/then/fi into the snippet like below.
Same might apply to "virt_console_post".
Thanks for reporting this.
Ironically, the reason I kept the condition outside the snippet in the first place was to avoid breaking existing snippets :-) The previous version had the template conditional outside the snippets, like this:
{% if distro is osmajor('RedHatEnterpriseLinux6', 'RedHatEnterpriseLinuxGrid6') %} {% snippet 'readahead_sysconfig' %} {% endif %}
So if I moved the conditional inside the snippet, then a custom snippet would suddenly become unconditional (unless the admin also updated their custom snippet to add the conditional).
However I clearly didn't account for the fact that an empty snippet would make it a syntax error.
Probably the best solution is to just add a dummy statement after the "then" statement to make it syntactically valid even if the snippet is empty. I guess this should work:
if [ -f /etc/sysconfig/readahead ] ; then : {% snippet 'readahead_sysconfig' %} fi