Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 742
coffee-grinder Avatar asked Dec 27 '22 22:12

coffee-grinder


2 Answers

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.

like image 170
Matthew Rankin Avatar answered Jan 10 '23 16:01

Matthew Rankin


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.

like image 31
lobster1234 Avatar answered Jan 10 '23 17:01

lobster1234