Fabric集群简单部署

from fabric.api import * 


env.roledefs={
    'TEST_72_CS' : [''],
    'TEST_72_DS' : [',
    'TEST_72' : [],
}


env.user=''
env.password=''


@roles('TEST_72')
def cp_tool(des='~/tair_bin'):
    put('/Users/harry/Src/killp.sh','~/killp.sh') 


@roles('TEST_72')
def cp_tair(des='~/tair_bin'):
    run("rm -rf %s" % des)
    run("rm -rf ~/my_tair.tar.gz")
    put('/Users/harry/Src/my_tair.tar.gz','~/my_tair.tar.gz') 
    run("tar zvxf ~/my_tair.tar.gz")


@roles('TEST_72')
def cp_etc(des='~/tair_bin'):
    put('/Users/harry/Src/tair_bin/etc/configserver.conf', '~/tair_bin/etc/configserver.conf')
    put('/Users/harry/Src/tair_bin/etc/dataserver.conf', des + '/etc/dataserver.conf')
    put('/Users/harry/Src/tair_bin/etc/group.conf', des + '/etc/group.conf')


@roles('TEST_72_CS')
def start_cs(des='~/tair_bin'):
    with cd (des):
        run('./tair.sh start_cs')


@roles('TEST_72_DS')
def start_ds(des='~/tair_bin'):
    with cd (des):
        run('./tair.sh start_ds')


@roles('TEST_72_CS')
def stop_cs(des):
    with cd (des):
        run('./tair.sh stop_cs')


@roles('TEST_72_DS')
def stop_ds(des):
    with cd (des):
        run('./tair.sh stop_ds')


def tar_tair(des='~/my_tair'):
    local("tar -czf my_tair.tar.gz tair_bin")


def init_tair(des='~/tair_bin'):
    cp_etc(des)
    stop_cs(des)
    stop_ds(des)
    start_cs(des)
    start_ds(des)


def start_tair(des='~/tair_bin'):
    #stop_cs(des)
    #stop_ds(des)
    start_cs(des)
    start_ds(des)


@roles('TEST_72')
def stop_tair(des='~/tair_bin'):
    with settings(warn_only=True):
        run('bash killp.sh')
        run('rm -rf ~/tair_bin/logs')

你可能感兴趣的:(开发环境,fabric,python)