Skip to content

Instantly share code, notes, and snippets.

@daviddyball
Created August 20, 2015 16:04
Show Gist options
  • Save daviddyball/7c2a97d8cd3794eb327f to your computer and use it in GitHub Desktop.
Save daviddyball/7c2a97d8cd3794eb327f to your computer and use it in GitHub Desktop.
import os
from invoke import run
from jinja2 import Template
class TemplateError(Exception):
pass
def template_file(filename):
if not os.path.isfile(filename):
raise TemplateError("%s is not a valid template file" % filename)
template = Template(open(filename, 'r').read())
rendered_template = template.render(os.environ)
os.unlink(filename)
with open(filename, 'w') as target_file:
target_file.write(rendered_template)
def run_supervisor():
run('supervisord -n')
def main():
template_file('/etc/nginx/sites-enabled/default')
template_file('/etc/php5/fpm/pool.d/zabbix.conf')
run_supervisor()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment