Snowblink
FEB 06
24

SwitchTower: Other Uses

SwitchTower allows you to easily deploy your Rails applications to your server farms.

I have only started playing with it recently, but found quite a nice use for it which is not Rails related: security patches.

Now, if you have just one system to update, it's not too much of a bother. As the number of systems you administer increases, so does the time it takes to apply security patches.

Using SwitchTower means that I don't have to write a separate script to update servers, which would probably involve expect. SwitchTower will only ask for your password once, then it applies that password throughout the task.

Here's how I did it. I created a Rails application:

$ rails linux_servers

Created the default switchtower files:

$ switchtower -A ./linux_servers LinuxServers

Now I just edited deploy.rb to include:

role :dev, *%w(dev1 dev2 dev3) role :test, *%w(test1 test2 test3) role :live, *%w(live1 live2 live3)

desc "Update servers" task :update_servers, :roles => [:dev, :test, :live] do sudo "apt-get update" sudo "apt-get -y upgrade" end

To execute:

$ rake remote_exec ACTION=update_servers

And that's just saved me minutes of tedium every time I have to patch servers. Yay!

Tagged As

Add a comment

Jamis Buck wrote over 4 years ago

Great application of SwitchTower! Thanks for sharing. Just FYI, you don't even need to generate a rails app to use it. You can just invoke SwitchTower directly on any arbitrary recipe file: switchtower -vvv -r recipes -a update_servers (where 'recipes.rb' is your recipes file, and is located in the current directory)