コード例 #1
0
ファイル: project.py プロジェクト: pombredanne/moment-1
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()
コード例 #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)
コード例 #3
0
ファイル: machine.py プロジェクト: FashtimeDotCom/moment
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)
コード例 #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)
コード例 #5
0
ファイル: project.py プロジェクト: FashtimeDotCom/moment
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()
コード例 #6
0
ファイル: gunicorn.py プロジェクト: mativs/oparupi
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)
コード例 #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))
コード例 #8
0
ファイル: nginx.py プロジェクト: mativs/oparupi
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")
コード例 #9
0
ファイル: gunicorn.py プロジェクト: mativs/oparupi
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))
コード例 #10
0
ファイル: app.py プロジェクト: 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)
コード例 #11
0
ファイル: app.py プロジェクト: 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)
コード例 #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")
コード例 #13
0
ファイル: project.py プロジェクト: pombredanne/moment-1
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()
コード例 #14
0
ファイル: project.py プロジェクト: FashtimeDotCom/moment
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()
コード例 #15
0
ファイル: nginx.py プロジェクト: pombredanne/fabix
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)
コード例 #16
0
ファイル: project.py プロジェクト: FashtimeDotCom/moment
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")
コード例 #17
0
ファイル: project.py プロジェクト: pombredanne/moment-1
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')
コード例 #18
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
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)
コード例 #19
0
ファイル: nginx.py プロジェクト: pombredanne/fabix
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)
コード例 #20
0
ファイル: nginx.py プロジェクト: pombredanne/fabix
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)
コード例 #21
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
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)
コード例 #22
0
ファイル: nginx.py プロジェクト: vinimalavolta/fabix
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)
コード例 #23
0
ファイル: project.py プロジェクト: FashtimeDotCom/moment
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()
コード例 #24
0
ファイル: project.py プロジェクト: pombredanne/moment-1
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()
コード例 #25
0
ファイル: machine.py プロジェクト: FashtimeDotCom/moment
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'])
コード例 #26
0
ファイル: django.py プロジェクト: mativs/oparupi
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))
コード例 #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'])
コード例 #28
0
ファイル: environ.py プロジェクト: ydaniv/quilt
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)
コード例 #29
0
ファイル: django.py プロジェクト: joeykennedy/pipfix
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))