示例#1
0
def full_deploy():
    """ Prepares server and deploys the project. """
    os = utils.detect_os()
    if not console.confirm("Is the OS detected correctly (%s)?" % os, default=False):
        abort("Detection fails. Please set env.conf.OS to correct value.")
    system.prepare_server()
    deploy_project()
示例#2
0
def full_deploy():
    """ Prepares server and deploys the project. """
    os = utils.detect_os()
    if not console.confirm("Is the OS detected correctly (%s)?" % os,
                           default=False):
        abort("Detection fails. Please set env.conf.OS to correct value.")
    system.prepare_server()
    deploy_project()
示例#3
0
def go_setup(stage="development"):
    """
	Install the correct services on each machine
	
    $ fab -i deploy/[your private SSH key here] set_hosts go_setup
	"""
    stage_exists(stage)
    PROVIDER = get_provider_dict()

    # Determine if a master/slave relationship exists for databases in config
    slave = []
    for db in ['mysql', 'postgresql', 'postgresql-client']:
        slave.append(
            any([
                'slave'
                in PROVIDER['machines'][stage][name].get('services',
                                                         {}).get(db, {})
                for name in PROVIDER['machines'][stage]
            ]))
    replication = any(slave)

    # Begin installing and setting up services
    for name in PROVIDER['machines'][stage]:
        node_dict = PROVIDER['machines'][stage][name]
        host = node_dict['public_ip'][0]
        if host == fabric.api.env.host:
            set_hostname(name)
            prepare_server()
            for service in node_dict['services'].keys():
                settings = node_dict['services'][service]
                if service == 'nginx':
                    nginx_install()
                    nginx_setup(stage=stage)
                elif service == 'redis':
                    redis_install()
                    redis_setup()
                elif service == 'uwsgi':
                    uwsgi_install()
                    uwsgi_setup(stage=stage)
                elif service == 'mysql':
                    mysql_install()
                    mysql_setup(stage=stage,
                                replication=replication,
                                **settings)
                elif service == 'postgresql':
                    postgresql_install(name,
                                       node_dict,
                                       stage=stage,
                                       **settings)
                    postgresql_setup(name, node_dict, stage=stage, **settings)
                elif service == 'postgresql-client':
                    postgresql_client_install()
                elif service in ['apache']:
                    fabric.api.warn(
                        fabric.colors.yellow("%s is not yet available" %
                                             service))
                else:
                    fabric.api.warn('%s is not an available service' % service)
示例#4
0
def go_setup(stage="development"):
    """
    Install the correct services on each machine

    $ fab -i deploy/[your private SSH key here] set_hosts go_setup
    """
    stage_exists(stage)
    PROVIDER = get_provider_dict()

    # Determine if a master/slave relationship exists for databases in config
    slave = []
    for db in ['mysql', 'postgresql', 'postgresql-client']:
        slave.append(
            any(['slave' in PROVIDER['machines'][stage][name].get(
                'services', {}).get(
                    db, {}) for name in PROVIDER['machines'][stage]]))
    replication = any(slave)

    # Begin installing and setting up services
    for name in PROVIDER['machines'][stage]:
        instance_dict = PROVIDER['machines'][stage][name]
        host = instance_dict['public_ip'][0]
        if host == fabric.api.env.host:
            set_hostname(name)
            prepare_server()
            for service in instance_dict['services'].keys():
                settings = instance_dict['services'][service]
                if service == 'nginx':
                    nginx_install()
                    nginx_setup(stage=stage)
                elif service == 'redis':
                    redis_install()
                    redis_setup()
                elif service == 'nodejs':
                    nodejs_install()
                    nodejs_setup()
                elif service == 'uwsgi':
                    uwsgi_install()
                    uwsgi_setup(stage=stage)
                elif service == 'mysql':
                    mysql_install()
                    mysql_setup(stage=stage, replication=replication, **settings)
                elif service == 'postgresql':
                    postgresql_install(name, instance_dict, stage=stage, **settings)
                    postgresql_setup(name, instance_dict, stage=stage, **settings)
                elif service == 'postgresql-client':
                    postgresql_client_install()
                elif service in ['apache']:
                    fabric.api.warn(fabric.colors.yellow("%s is not yet available" % service))
                else:
                    fabric.api.warn('%s is not an available service' % service)
示例#5
0
def deploy_prepare():
    u"""
    Подготовка удалённого сервера к установке ПО.
    """
    print deploy_prepare.__doc__
    # устанавливаем sudo, настраиваем backports
    system.prepare_server()

    # создаём виртуальное окружение
    virtualenv.virtualenv_create()

    # устанавливаем APT и PIP пакеты
    packages = ' '.join(APT)
    system.aptitude_install(packages)
    packages = ' '.join(PIP)
    pip_install(packages)

    # устанавливаем общие зависимости
    put('./reqs', '~/')
    pip_install('-r reqs/apps.txt')

    # перекидываем код на сервер
    rsync_codebase()