How to set target hosts in Fabric file

后端 未结 15 785
南方客
南方客 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:07

    You need to modify env.hosts at the module level, not within a task function. I made the same mistake.

    from fabric.api import *
    
    def _get_hosts():
        hosts = []
        ... populate 'hosts' list ...
        return hosts
    
    env.hosts = _get_hosts()
    
    def your_task():
        ... your task ...
    

提交回复
热议问题