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_
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 ...