Why re-implement shell commands line by line in a Fabric script?
Fabric is a tool for "executing local or remote shell commands."
Why would you re-implement a remote shell script line by line in a long Fabric script?
That is, why not just write a brief Fabric script that runs a long remote shell 开发者_如何学编程script instead?
lobster1234 raises a good point that you don't want to have to manually stick a long, remote shell script on 10 servers. However, if you still want to avoid rewriting the long, remote shell script as a long Fabric script, you could write a Fabric script that copies that remote shell script to the designated server, executes that script, and then removes the script. This way you can revision control both the fabfile and shell script together but avoid rewriting the shell script into a Fabric script.
It wont be a good idea if I have to run the same script on, lets say, 10 servers. This means I've to not only stick the same long script on 10 servers, but also make sure if I change it on 1 server, the change has to be applied to all servers. I know this can be averted by keeping that script on a shared location, but its much more organized to have the script in the fabfile, which can not only be version controlled but kept uniform across all the roles.
Also, I think the path you'd choose would depend on what you're trying to do. Some things are easier in python (write it in your fabfile), while others are easier in shell-land (take one of the shell approaches mentioned).
Either way, fabric is geared towards centralization and portability, and it doesn't really matter what's actually doing the lifting.
精彩评论