How to set target hosts in Fabric file

后端 未结 15 782
南方客
南方客 2020-11-29 15:27

I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:

def deploy_2_dev():
  deploy(\'dev\')

def deploy_         


        
15条回答
  •  孤城傲影
    2020-11-29 16:08

    So, in order to set the hosts, and have the commands run across all the hosts, you have to start with:

    def PROD():
        env.hosts = ['10.0.0.1', '10.0.0.2']
    
    def deploy(version='0.0'):
        sudo('deploy %s' % version)
    

    Once those are defined, then run the command on the command line:

    fab PROD deploy:1.5
    

    What will run the deploy task across all of the servers listed in the PROD function, as it sets the env.hosts before running the task.

提交回复
热议问题