If you’re running servers in the cloud, particularly on Amazon’s AWS and haven’t heard about RightScale you owe it to yourself to check them out. I’ve been using their tools for launching and managing linux servers on AWS. They allow you to automate all of the tasks to launch a new box, and even run regular operational tasks, all with the use of RightScripts.
RightScripts are just glorified shell scripts which get downloaded from RightScale to your linux server running in any of the clouds they support, and executed with the parameters that you specify in the RightScale dashboard for that RightScript. Of course, as you start to get into more complex scenarios you’re likely to start writing and testing your scripts locally before saving them in the RightScale dashboard. That’s where RightScriptDiff comes in.
The only way to create or edit a RightScript as of this writing is through the RightScale dashboard. So you’re typing your script into a nice big textarea, where you can’t tab for indents or any of the other benefits you get from an editor like vim, emacs, or even gasp notepad.exe. As a result I started to write, and even test my scripts locally before I ever committed them to RightScale.
Going this route of course adds a fair amount of overhead to the process. You have to remember which scripts you’ve edited, then copy/paste them into the RightScale dashboard to update the script in their system. After a while I found I couldn’t keep up with the overhead, and I needed to find some good way to compare my local copies of scripts with the ones in my RightScale dashboard.
Thus was born RightScriptDiff. By supplying RightScriptDiff with your username, password, and account id for RightScale along with a path to a directory containing your local scripts, it will use the RightScale API to compare your local copy against the one stored in your RightScale account. If you’re thinking “why don’t you just synchronize the script using the API”, you’re on the right track. Sadly, the API doesn’t (yet) support RightScripts for anything but viewing, here’s hoping they open up that functionality a bit.
In order for RightScriptDiff to compare your local files, they must be named with a specific pattern, namely <rightscript_id>–<rightscript_name>.sh. Actually, the script name and the .sh extension are optional, but that’s the convention I use so it’s easier to identify them. You can pass (almost) any argument to RightScriptDiff that you can to the “ls” command in nix and OSX, so something like relative/path/to/RightScripts/*.sh is totally acceptable. This means you can also target just a single script if you’d like. RightScriptDiff uses the RightScript_ID section of the filename to look up the script using the RightScript API, then compares the script against your local copy. If they’re the same, you get a happy success message that there is no difference. If the files are different, a side by side diff is shown.
Here’s an example of a successful run;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
This is what it looks like when the scripts differ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
As mentioned above RightScriptDiff requires three values, your RightScale account email address, password, and account number. You might notice that in both instances above I did not need to provide them and was prompted only for the path to my scripts. This is because I pre-defined my credentials and account before hand. There are a couple ways to provide this to RightScriptDiff, you can call rsDiff.sh with parameters (-e|—email=)<email-address> (-p|—password=)<password> (-a|—account_id=)<account_id>, or you can rename the supplied rsDiffAuth.sh.example file, to rsDiffAuth.sh and put your credentials in there.
After developing this, I discovered that I had edited one of my script files locally and the change wasn’t reflected in my RightScale dashboard, so it’s already proved useful to me. Hopefully this helps some other sysadmins building our their RightScale managed clouds.
You can download RightScriptDiff by running the following command. I wrote it on OSX 10.6.4, but it should work on most flavors of linux as well.
1
|
|
* UPDATE: RightScriptDiff has a new home
1
|
|
Chances are pretty good I’ll create a landing page for this, particularly if it becomes popular, so stay tuned here for updates!