Gyan Veda Gyan Veda - 1 year ago 86
Python Question

Can I have multiple Python fabfiles in one project directory?

I have a project that has a local copy in my machine and a remote copy in a server, Server 1. Currently, I use Fabric to update the remote copy when I make changes to my local copy. To do this, a fab file is located in the root directory of the project (e.g.,


I would like to use Fabric in this project for a second purpose. One of the functions in this project needs to connect to a different server, Server 2. Can I create a second fab file in the subdirectory of the project that contains the relevant code (e.g.,

I am new to Fabric so I just want to make sure that I'm using Fabric in a way that won't cause the two fab files to interfere with each other.

Also, because I'm new to Fabric I may not be describing this situation appropriately. Please let me know if you need to know any additional information.

Answer Source

I have learned that a single fab file is enough for a project. Instead, it is best to have a single fab file that defines multiple functions that each make use of a different server. Fabric documentation offers a few ways to do this, depending on the specific needs of the user.

In my case, I modified my single fab file to look like this:

def server1_task():

def server2_task():