Example #1
0
def ensure_production_settings():
    notify('Configuring production settings.')
    context = SENSITIVE
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.production_settings, context)
    cuisine.file_write(PROJECT['ROOT'] + '/moment/conf/production.py', content)
    restart()
Example #2
0
def hosts_conf():
    notify('Writing hostname and hosts files.')
    cuisine.mode_sudo()
    sudo('echo "{NAME}" > /etc/hostname'.format(NAME=MACHINE['KEY']))
    sudo('hostname -F /etc/hostname')
    hosts = cuisine.text_template(templates.hosts, MACHINE)
    cuisine.file_append('/etc/hosts', hosts)
Example #3
0
def hosts_conf():
    notify('Writing hostname and hosts files.')
    cuisine.mode_sudo()
    sudo('echo "{NAME}" > /etc/hostname'.format(NAME=MACHINE['KEY']))
    sudo('hostname -F /etc/hostname')
    hosts = cuisine.text_template(templates.hosts, MACHINE)
    cuisine.file_append('/etc/hosts', hosts)
Example #4
0
def gunicorn_process_ensure(path, template, config, key_env, venv_path='.venv'):
    with virtualenv(path, venv_path):
        python_package_ensure('gunicorn')
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x,key_env))
        dir_ensure('%s/logs' % path)
        dir_ensure('%s/run' % path)
Example #5
0
def ensure_production_settings():
    notify("Configuring production settings.")
    context = SENSITIVE
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.production_settings, context)
    cuisine.file_write(PROJECT["ROOT"] + "/moment/conf/production.py", content)
    restart()
Example #6
0
def gunicorn_ensure(path, template, config, venv_path='.venv'):
    with virtualenv(path, venv_path):
        python_package_ensure('gunicorn')
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x,env))
        dir_ensure('%s/logs' % path)
        dir_ensure('%s/run' % path)
Example #7
0
def gunicorn_supervisor_ensure(project_path, project_name, template, key_env):
    with mode_sudo(), cd(project_path):
        config = '/etc/supervisor/conf.d/%s.conf' % project_name
        package_ensure('supervisor')
        python_package_ensure('setproctitle')
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x,key_env))
        run("supervisorctl reread")
        run("supervisorctl update")
        run("supervisorctl restart %s" % (project_name))
Example #8
0
def nginx_ensure(name, template):
	with mode_sudo():
	    package_ensure('nginx') 
	    run("cp %s /etc/nginx/sites-available/%s" % (template, name))
	    file_update('/etc/nginx/sites-available/%s' % name, lambda x: text_template(x,env))
	    if not file_exists("/etc/nginx/sites-enabled/%s" % name):
	        run("ln -s -t /etc/nginx/sites-enabled /etc/nginx/sites-available/%s " % (
	            env.project_name))
	    file_unlink('/etc/nginx/sites-enabled/default')
	    run("service nginx restart")
Example #9
0
def gunicorn_supervisor_ensure(project_name, template):
    with mode_sudo():
        config = '/etc/supervisor/conf.d/%s.conf' % project_name
        package_ensure('supervisor')
        python_package_ensure('setproctitle')
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x,env))
        run("supervisorctl reread")
        run("supervisorctl update")
        run("supervisorctl restart %s" % (project_name))
Example #10
0
File: app.py Project: ydaniv/quilt
def config():
    """Ensures the app configuration is in place."""

    utilities.notify(u'Ensuring the app configuration settings.')

    context = env
    cuisine.mode_sudo()
    content = cuisine.text_template(env.app_config_template, context)
    cuisine.file_write(env.app_config_file, content)
    execute(restart)
Example #11
0
File: app.py Project: ydaniv/quilt
def management():
    """Ensures the app process management is in place."""

    utilities.notify(u'Ensuring the app management settings.')

    context = env
    cuisine.mode_sudo()
    content = cuisine.text_template(env.app_management_template, context)
    cuisine.file_write(env.app_management_file, content)
    execute(update)
    execute(restart)
Example #12
0
def nginx_ensure(project_path, name, template, key_env):
	with mode_sudo(), cd(project_path):
	    package_ensure('nginx') 
	    run("cp %s /etc/nginx/sites-available/%s" % (template, name))
	    file_update('/etc/nginx/sites-available/%s' % name,
            lambda x: text_template(x,key_env))
	    if not file_exists("/etc/nginx/sites-enabled/%s" % name):
	        run("ln -s -t /etc/nginx/sites-enabled /etc/nginx/sites-available/%s " % (
	            name))
	    file_unlink('/etc/nginx/sites-enabled/default')
	    run("service nginx restart")
Example #13
0
def ensure_rq():
    notify('Configuring RQ.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'PROJECT_ROOT': PROJECT['ROOT'],
        'PROJECT_ENV': PROJECT['ENV'],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.rq_supervisor, context)
    cuisine.file_write('/etc/supervisor/conf.d/' + KEY + '-rq.conf', content)
    restart()
Example #14
0
def ensure_rq():
    notify("Configuring RQ.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "PROJECT_ROOT": PROJECT["ROOT"],
        "PROJECT_ENV": PROJECT["ENV"],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.rq_supervisor, context)
    cuisine.file_write("/etc/supervisor/conf.d/" + KEY + "-rq.conf", content)
    restart()
Example #15
0
def install_nginx_upstart(version):
    """Install nginx upstart config."""

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    nginx_bin = os.path.join(install_dir, 'sbin', 'nginx')
    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_bin': nginx_bin,
        'nginx_pid': nginx_pid,
    }

    nginx_tpl = os.path.join(ETC_DIR, 'init', 'nginx.conf')
    tpl_content = file_local_read(nginx_tpl)
    content = text_template(tpl_content, context)

    with mode_sudo():
        file_write('/etc/init/nginx.conf', content)
Example #16
0
def ensure_nginx():
    notify("Configuring nginx.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "APP_LOCATION": PROJECT["APP_LOCATION"],
        "APP_PORT": PROJECT["APP_PORT"],
        "LOCATION": MACHINE["LOCATION"],
        "PORT": MACHINE["PORT"],
        "PROJECT_ROOT": PROJECT["ROOT"],
        "ACCESS_LOG": PROJECT["LOGS"]["NGINX_ACCESS"],
        "ERROR_LOG": PROJECT["LOGS"]["NGINX_ERROR"],
        "SERVER_NAMES": " ".join(PROJECT["DOMAINS"]),
    }
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.nginx, context)
    cuisine.file_write("/etc/nginx/sites-enabled/" + KEY, content)
    sudo("/etc/init.d/nginx restart")
Example #17
0
def ensure_nginx():
    notify('Configuring nginx.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'APP_LOCATION': PROJECT['APP_LOCATION'],
        'APP_PORT': PROJECT['APP_PORT'],
        'LOCATION': MACHINE['LOCATION'],
        'PORT': MACHINE['PORT'],
        'PROJECT_ROOT': PROJECT['ROOT'],
        'ACCESS_LOG': PROJECT['LOGS']['NGINX_ACCESS'],
        'ERROR_LOG': PROJECT['LOGS']['NGINX_ERROR'],
        'SERVER_NAMES': ' '.join(PROJECT['DOMAINS'])
    }
    cuisine.mode_sudo()
    content = cuisine.text_template(templates.nginx, context)
    cuisine.file_write('/etc/nginx/sites-enabled/' + KEY, content)
    sudo('/etc/init.d/nginx restart')
Example #18
0
def install_upstart():
    """Install nginx upstart config."""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    nginx_bin = os.path.join(install_dir, 'sbin', 'nginx')
    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_bin': nginx_bin,
        'nginx_pid': nginx_pid,
    }

    nginx_tpl = os.path.join(ETC_DIR, 'init', 'nginx.conf')
    tpl_content = cuisine.file_local_read(nginx_tpl)
    content = cuisine.text_template(tpl_content, context)

    with cuisine.mode_sudo():
        cuisine.file_write('/etc/init/nginx.conf', content)
Example #19
0
def install_nginx_site_conf(version, nginx_file, context=None):
    """Install nginx config per site."""

    if not os.path.exists(nginx_file):
        abort("Nginx conf {0} not found".format(nginx_file))

    site_name = os.path.basename(nginx_file)

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'sites-enabled', site_name)

    if context:
        tpl_content = open(nginx_file, 'rb').read()
        content = text_template(tpl_content, context)

        with mode_sudo():
            file_write(conf_file, content)
    else:
        with mode_sudo():
            file_upload(conf_file, nginx_file)
Example #20
0
def install_nginx_conf(version, nginx_file):
    """Install global nginx config."""

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'nginx.conf')

    if not os.path.exists(nginx_file):
        abort("Nginx conf {0} not found".format(nginx_file))

    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_user': NGINX_USER,
        'nginx_pid': nginx_pid,
    }

    tpl_content = open(nginx_file, 'rb').read()
    content = text_template(tpl_content, context)

    with mode_sudo():
        file_write(conf_file, content)
Example #21
0
def put_site_conf(nginx_file, context=None):
    """Install nginx config per site."""
    version = get_config()['version']

    if not os.path.exists(nginx_file):
        fab.abort("Nginx conf {0} not found".format(nginx_file))

    site_name = os.path.basename(nginx_file)

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'sites-enabled', site_name)

    if context:
        tpl_content = open(nginx_file, 'rb').read()
        content = cuisine.text_template(tpl_content, context)

        with cuisine.mode_sudo():
            cuisine.file_write(conf_file, content)
    else:
        with cuisine.mode_sudo():
            cuisine.file_upload(conf_file, nginx_file)
Example #22
0
def put_conf(nginx_file):
    """Install global nginx config."""
    version = get_config()['version']

    install_dir = os.path.join(_INSTALL_DIR, 'nginx', version)
    conf_file = os.path.join(install_dir, 'conf', 'nginx.conf')

    if not os.path.exists(nginx_file):
        fab.abort("Nginx conf {0} not found".format(nginx_file))

    nginx_pid = os.path.join(install_dir, 'logs', 'nginx.pid')

    context = {
        'nginx_user': NGINX_USER,
        'nginx_pid': nginx_pid,
    }

    tpl_content = open(nginx_file, 'rb').read()
    content = cuisine.text_template(tpl_content, context)

    with cuisine.mode_sudo():
        cuisine.file_write(conf_file, content)
Example #23
0
def ensure_gunicorn():
    notify("Configuring gunicorn.")
    context = {
        "ACTION_DATE": MACHINE["ACTION_DATE"],
        "NAME": PROJECT["NAME"],
        "KEY": KEY,
        "APP_LOCATION": PROJECT["APP_LOCATION"],
        "APP_PORT": PROJECT["APP_PORT"],
        "APP_TIMEOUT": PROJECT["APP_TIMEOUT"],
        "APP_WSGI": PROJECT["APP_WSGI"],
        "APP_WORKERS": PROJECT["APP_WORKERS"],
        "LOCATION": MACHINE["LOCATION"],
        "PORT": MACHINE["PORT"],
        "PROJECT_ROOT": PROJECT["ROOT"],
        "PROJECT_ENV": PROJECT["ENV"],
        "ACCESS_LOG": PROJECT["LOGS"]["GUNICORN_ACCESS"],
        "ERROR_LOG": PROJECT["LOGS"]["GUNICORN_ERROR"],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.gunicorn_supervisor, context)
    cuisine.file_write("/etc/supervisor/conf.d/" + KEY + "-gunicorn.conf", content)
    restart()
Example #24
0
def ensure_gunicorn():
    notify('Configuring gunicorn.')
    context = {
        'ACTION_DATE': MACHINE['ACTION_DATE'],
        'NAME': PROJECT['NAME'],
        'KEY': KEY,
        'APP_LOCATION': PROJECT['APP_LOCATION'],
        'APP_PORT': PROJECT['APP_PORT'],
        'APP_TIMEOUT': PROJECT['APP_TIMEOUT'],
        'APP_WSGI': PROJECT['APP_WSGI'],
        'APP_WORKERS': PROJECT['APP_WORKERS'],
        'LOCATION': MACHINE['LOCATION'],
        'PORT': MACHINE['PORT'],
        'PROJECT_ROOT': PROJECT['ROOT'],
        'PROJECT_ENV': PROJECT['ENV'],
        'ACCESS_LOG': PROJECT['LOGS']['GUNICORN_ACCESS'],
        'ERROR_LOG': PROJECT['LOGS']['GUNICORN_ERROR'],
    }

    cuisine.mode_sudo()
    content = cuisine.text_template(templates.gunicorn_supervisor, context)
    cuisine.file_write('/etc/supervisor/conf.d/' + KEY + '-gunicorn.conf',
                       content)
    restart()
Example #25
0
def profile_conf():
    notify('Configuring .profile settings.')
    profile = cuisine.text_template(templates.profile, MACHINE)
    cuisine.file_append(MACHINE['OWNER_PROFILE'], profile)
    run('source ' + MACHINE['OWNER_PROFILE'])
Example #26
0
def django_config_ensure(path, template, config):
    with cd(path):
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x,env))
Example #27
0
def profile_conf():
    notify('Configuring .profile settings.')
    profile = cuisine.text_template(templates.profile, MACHINE)
    cuisine.file_append(MACHINE['OWNER_PROFILE'], profile)
    run('source ' + MACHINE['OWNER_PROFILE'])
Example #28
0
def ensure_settings():
    utilities.notify(u'Configuring local settings.')

    context = env
    content = cuisine.text_template(env.project_config_template, context)
    cuisine.file_write(env.project_config_file, content)
Example #29
0
def django_config_ensure(project_path, template, config, key_env):
    with cd(project_path):
        run("cp %s %s" % (template, config))
        file_update(config, lambda x: text_template(x, key_env))