On Sat, Mar 5, 2011 at 7:49 AM, Robin Bowes <[email protected]> wrote:
> On 05/03/11 03:08, Donovan Bray wrote:
>> You can look here for an example
>>
>> http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano
>>
>
> Donovan,
>
> Can you explain how "scalr_hosts['foo']" works?
>
> R.
> --
> "Feed that ego and you starve the soul" - Colonel J.D. Wilkes
> http://www.theshackshakers.com/
>

I found this a little confusing as well.  It's no fault of Donovan's
code, as he says he does in fact provide the code where the hash is
being populated.

What was unclear to me is that you can use any code you want to set
the lists of hosts to be used in that role.  In my case, I just used a
function.  Here's my simple role definitions:


role(:web)  do
   compute_serverlist
end

role(:app)  do
   compute_serverlist
end

(I wish I understood how to define both :web and :app in a single go,
but I'm not sure if that's possible)

Anyway, the compute_serverlist function queries some JSON in my case
to get the list of servers, but can be literally *anything* you want
to use, as long as it returns an array of servers:

def compute_serverlist
  cde_servers_json=Net::HTTP.get 'serverlist.bluestatedigital.com',
'/group/web-cde'
  serverlist=JSON.parse(cde_servers_json)
  serverlist
end

For debugging, I just have the function return the single value of my
test machine:


def compute_serverlist
   ["build1.bluestatedigital.com"]
end

Hope this helps.

-Chris
-- 
Christopher Patti - Geek At Large | GTalk: [email protected] | AIM:
chrisfeohpatti | P: (260) 54PATTI
"Technology challenges art, art inspires technology." - John Lasseter, Pixar

-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to