Re: [capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-07 Thread Robin Bowes
On 06/03/11 11:32, Donovan Bray wrote:
 scalr_hosts['foo'] is just a simple hash
 

Ah, OK. Thanks.

R. (not familiar with ruby)

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


Re: [capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-05 Thread Robin Bowes
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/

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


[capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-04 Thread Chris Patti
Folks;

I have a task:

   task :readserverlist do
  cde_servers_json=Net::HTTP.get
'serverlist.bluestatedigital.com', '/group/web-cde'
  pp JSON.parse(cde_servers_json)
   end

What I want is the results of this JSON query to set the list of
servers to deploy to at run time.

Is this possible, and if so, can someone give me an example of how
this is done? I've found people talking about assigning roles
dynamically at run time, but I can't extrapolate how to apply those to
my situation (probably because I'm a total capistrano newbie :)

Any clues would be much appreciated.

Thanks!
-Chris


-- 
Christopher Patti - Geek At Large | GTalk: cpa...@gmail.com | 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 capistrano@googlegroups.com
* To unsubscribe from this group, send email to 
capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en


Re: [capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-04 Thread Chris Patti
On Fri, Mar 4, 2011 at 3:59 PM, Lee Hambley lee.hamb...@gmail.com wrote:
 Chris,
 This isn't perfect - but is effectively what you are trying to do
 - https://github.com/leehambley/capistrano-yaml-multistage
 I can't remember if the current master there runs out of the box… but
 there's not a lot of code, and it's pretty light on magic.
 - HTH, Lee


Thanks Lee.

So, reading through your code, it looks like the salient bit is:

puts Setting role of #{role_key} to #{role_value}
role(role_key.to_sym, role_value.to_s)

Can you please tell me where the role() routine is defined? Should I
just call this in my custom task?

Based on another example:

http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano

I tried adding a role definition like he did, which has inside of the
role :web do block the array I generated in my task, but then I get
the exception I include in full below.

I've put the entire deploy.rb into a pastie:

http://pastie.org/1634110

Thanks for any clues.

-Chris
--
[16:45][cpatti@box42-142:~/src/cde-test/config(rel-113)]$ cap  deploy
--set change_id=99 bsd:readserverlist
  * executing `deploy'
triggering before callbacks for `deploy'
  * executing `bsd:readserverlist'
  * executing `bsd:checkchangeid'
  * executing `bsd:deployconfirm'
This will deploy branch rel-113, are you sure? (yes/no): yes
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: git ls-remote
ssh://git.bluestatedigital.com/home/git/cde-test.git rel-113
  * executing if [ -d
/home/jsteadman/temp/cde-deploy/shared/cached-copy ]; then cd
/home/jsteadman/temp/cde-deploy/shared/cached-copy  git fetch -q
origin  git reset -q --hard 702118786e2c4f83eb98bfcd69078ce0db5761b6
 git clean -q -d -x -f; else git clone -q
ssh://git.bluestatedigital.com/home/git/cde-test.git
/home/jsteadman/temp/cde-deploy/shared/cached-copy  cd
/home/jsteadman/temp/cde-deploy/shared/cached-copy  git checkout -q
-b deploy 702118786e2c4f83eb98bfcd69078ce0db5761b6; fi
*** [deploy:update_code] rolling back
  * executing rm -rf
/home/jsteadman/temp/cde-deploy/releases/20110304214546; true
 ** [deploy:update_code] exception while rolling back: NoMethodError,
undefined method `match' for
#Capistrano::Configuration::Namespaces::Namespace:0x2a97004940
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/namespaces.rb:188:in
`method_missing': undefined method `match' for
#Capistrano::Configuration::Namespaces::Namespace:0x2a97004940
(NoMethodError)
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/server_definition.rb:16:in
`initialize'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:80:in
`new'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:80:in
`wrap_server'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:98:in
`wrap_list'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:97:in
`map'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:97:in
`wrap_list'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:59:in
`to_ary'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:74:in
`concat'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:74:in
`dynamic_servers'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`inject'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:74:in
`each'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:74:in
`inject'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:74:in
`dynamic_servers'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/role.rb:28:in
`to_ary'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:57:in
`concat'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:57:in
`find_servers'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`inject'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:57:in
`each'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:57:in
`inject'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:57:in
`find_servers'
from 
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.5.19/lib/capistrano/configuration/servers.rb:9:in
`find_servers_for_task'
from 

Re: [capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-04 Thread Chris Patti
On Fri, Mar 4, 2011 at 4:48 PM, Chris Patti cpa...@gmail.com wrote:
 On Fri, Mar 4, 2011 at 3:59 PM, Lee Hambley lee.hamb...@gmail.com wrote:
 Chris,
 This isn't perfect - but is effectively what you are trying to do
 - https://github.com/leehambley/capistrano-yaml-multistage
 I can't remember if the current master there runs out of the box… but
 there's not a lot of code, and it's pretty light on magic.
 - HTH, Lee


 Thanks Lee.

 So, reading through your code, it looks like the salient bit is:

        puts Setting role of #{role_key} to #{role_value}
        role(role_key.to_sym, role_value.to_s)

 Can you please tell me where the role() routine is defined? Should I
 just call this in my custom task?

 Based on another example:

 http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano

 I tried adding a role definition like he did, which has inside of the
 role :web do block the array I generated in my task, but then I get
 the exception I include in full below.

 I've put the entire deploy.rb into a pastie:

 http://pastie.org/1634110

 Thanks for any clues.

 -Chris

[stacktrace snip.  Sorry for breaking the ground rules folks :)]

OK, nailed it.  Turns out I was making this way more complex than it
needed to be.  After a re-read of the DSL docs:

https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-Roles-Role

I found that all I needed to do was put my JSON querying code that
returns a list of servers into a function, and then:

role(:web)  do
   compute_serverlist
end

Simple!  Thanks everyone.

-Chris


-- 
Christopher Patti - Geek At Large | GTalk: cpa...@gmail.com | 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 capistrano@googlegroups.com
* To unsubscribe from this group, send email to 
capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en


Re: [capistrano] Setting the list of webservers to deploy to through a JSON query

2011-03-04 Thread Donovan Bray
You can look here for an example

http://groups.google.com/group/scalr-discuss/web/scalr-with-capistrano

On Mar 4, 2011, at 12:27 PM, Chris Patti cpa...@gmail.com wrote:

 Folks;
 
 I have a task:
 
   task :readserverlist do
  cde_servers_json=Net::HTTP.get
 'serverlist.bluestatedigital.com', '/group/web-cde'
  pp JSON.parse(cde_servers_json)
   end
 
 What I want is the results of this JSON query to set the list of
 servers to deploy to at run time.
 
 Is this possible, and if so, can someone give me an example of how
 this is done? I've found people talking about assigning roles
 dynamically at run time, but I can't extrapolate how to apply those to
 my situation (probably because I'm a total capistrano newbie :)
 
 Any clues would be much appreciated.
 
 Thanks!
 -Chris
 
 
 -- 
 Christopher Patti - Geek At Large | GTalk: cpa...@gmail.com | 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 capistrano@googlegroups.com
 * To unsubscribe from this group, send email to 
 capistrano+unsubscr...@googlegroups.com For more options, visit this group at 
 http://groups.google.com/group/capistrano?hl=en

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