Watch out for fabric pitfalls


Fabric has been a very useful tool. It helps a lot in simplifying and documenting server deployments.

Recently I am tasked to convert a bash script web server setup file to a fabric deployment file. Of course due to some unfamiliarity with fabric, I thought by converting every single line of the bash script to fabric run(‘<command line from bash>’) it would work. Man, I was proven wrong again and again.

So I am blogging some of the pitfalls I have fallen into so that you don’t repeat my mistakes:

Bash Script: cd /opt/mongodb

Fabric: run('cd /opt/mono') WRONG

run don’t accept cd. It does not tell the server to go to the folder. You need to use another library The correct way is

with cd('/opt/mono'):

git clone

Bash Script: export CONFIG_PATH='/usr/lib/config'

Fabric: run("export CONFIG_PATH='/usr/lib/config'") WRONG

You cannot use run command in fabric to set environment variables. You need to use shell_env function, also under fabric context_manger library

with shell_env(CONFIG_PATH='/usr/lib/config')


Finally when you put files, it is advisable that you put(local filename, remote filename/folder). I experience that if you put both parameters as folders, the files that you transferred end up becomes 0 bytes


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s