Lately I’ve had the chance to dive much deeper into BASH than I ever have before. I’m working on a build system with a dozen or so library files, and as many client scripts for the actual builds. A big question is whether or not BASH is the best language for the system compared to scripting options like Python, Perl, Ruby, PHP >cough<, etc. Initially I wrote the entire build system in BASH. But given an opportunity to learn Python, and put the theory to the test, I decided to start implementing some of the components in Python to see what it could offer.
Months ago I was just getting my feet wet with Fabric and Python. Python is a pleasant language, I’m not sure how much I’ll do with it, but I’m happy to have ramped up on the basics. Fabric is nice too. Some of my original thoughts about designing my Python/Fabric setup have changed a bit over the past few months to reflect lessons from practical experience.
Today working with Fabric I found myself wondering if there is any way to pass a hash to a Fabric task. The reason being I didn’t know how many arguments I’d need to pass to a particular task during a given invocation. Fabric supports passing named arguments to task functions, turns out, it also supports variable arguments.
Since I’ve been using Fabric for over a month now, and working with BASH a lot lately, I realized one reason why Fabric might be slower than alternatives like MCollective and pexpect. Fabric executes each run invocation through a separate ssh connection. By combining a set of run calls into a single command and one run call, the same Fabric script can run much faster.
I’ve finally gotten to the point where I’m working with Puppet and automating application deployments. Initially I investigated Capistrano as I’ve heard so much about it over the years. I was sorely disappointed. I couldn’t figure out how to parameterize the hosts component of tasks and wasn’t interested in dirtying my projects with a config directory just for deployments. I turned to Fabric, and I’m not looking back!