Is it possible to access a OS environment variable directly from a Jinja2 template?
The answer in https://stackoverflow.com/a/27984610/1070890 works beautifully but you can still get rid of the useless use of cat and compress it to a single statement:
python -c 'import os
import sys
import jinja2
sys.stdout.write(
jinja2.Template(sys.stdin.read()
).render(env=os.environ))' <$CONFIGTEMPLATE >$CONFIGFILE
P.S.: Stack Overflow does not allow formatted code in comments. Therefore I had to post this as a separate answer instead of commenting on https://stackoverflow.com/a/27984610/1070890.