The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Using SwitchTower with multiple deployment stages

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jamis Buck

Posts: 184
Nickname: minam
Registered: Oct, 2004

Jamis Buck is a C/Java software developer for BYU, and hacks in Ruby for fun.
Using SwitchTower with multiple deployment stages Posted: Jan 3, 2006 3:46 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jamis Buck.
Original Post: Using SwitchTower with multiple deployment stages
Feed Title: the buckblogs here
Feed URL: http://weblog.jamisbuck.org/blog.cgi/programming/index.rss
Feed Description: Jamis Buck's corner of the blogging universe. Mostly about ruby, but includes ramblings on a variety of topics.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jamis Buck
Latest Posts From the buckblogs here

Advertisement

Back in August I blogged briefly about having a conditional SwitchTower configuration, which would allow you to specify a different configuration for various stages of deployment. Recently, people have been asking for “deploy_stage” and “deploy_production” in SwitchTower itself, but I’m pushing back. It seems to me that it is easy enough to do in SwitchTower that there doesn’t really need to be a specific feature set in ST for it (but you tell me).

Revisiting that entry, I wouldn’t do it much differently today. The deploy.rb would still look more or less like this:

  set :application, "example"
  if ENV["STAGE"] == "stage"
    set :deploy_to, "/u/apps/stage/#{application}"
    role :app, "staging.example.com"
    role :web, "staging.example.com"
    role :db,  "staging.example.com", :primary => true
  else
    role :app, "foo.example.com", "bar.example.com"
    role :web, "123.example.com",
    role :db,  "tiger.example.com", :primary => true
  end

It is as simple as an if statement, and it lets you configure multiple deployment stages (if you need them). If using environment variables is less than tasteful to you, you can also use ST variables:

  ...
  if stage == "stage"
    ...
  else
    ...
  end
  ...

You would then invoke the task like:

  switchtower -vvvv -S stage=production -r config/deploy -a deploy

(Note the use of a capital -S—this causes the variable to be set before the recipe file is loaded, which is necessary since the variable is referenced as the file is being read.)

Note that using a variable complicates things a little bit if you are using rake, because you can’t pass the variable to the ST task from the rake command-line. Instead, you’ll need to create a new rake task for each value you want to pass to the variable (i.e., deploy_stage and deploy_production). For this reason, I prefer to use environment variables, but your mileage may vary.

So, from those of you who need multiple deployment stages, is this sufficient for you? If not, why?

Read: Using SwitchTower with multiple deployment stages

Topic: Ruby Symbols are not Lisp symbols Previous Topic   Next Topic Topic: RMagick Project

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use