I wrote a similar package taking ideas from rails configuration: https://bitbucket.org/utils/config It provides different settings for different environments with templating support to use env vars.
I usually did that with puppet in my previous job to create different confs per server/stage.