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:
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 fabric.context_manager.cd. The correct way is
git clone http://github.com/mono.git
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
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