Created
August 20, 2015 16:04
-
-
Save daviddyball/7c2a97d8cd3794eb327f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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