Deploy with fabric on multiple servers

Ever needed to deploy with fabric on multiple machines?
Here’s a simple solution to aproach this issue.

In your fabfile.py , add these two methods:

Now, when deploying, for example:

you must use the following commands, in the correct order:

Fabric runs the “staging” or “deploy” commands first, setting the envrinoment variables, and then it runs the “deploy” command doing whatever you asked it to do.