Hi,
Actually you can set roles dynamically. There are 2 ways:
1) You can define you role as a block:
set(:myrole) { (fetch(:remote, nil) == nil) ? :local : :app }

The code inside the block can do actually anything.
Then you can use your role in tasks this way:
task :check_app_status, :roles => myrole do

The important thing here is that you must place "set(:myrole)" statement 
strictly before the definition of any task that uses "myrole".

2) The dirtier but more dynamic solution:
parent.roles[:myrole] = [] #clearing the role servers list
parent.role :myrole, server_host #appending the hostname to the role

Hope this would help.
--
Cheers,
Michael

ky wrote:
> I use Amazon's EC2 for my production system.  Currently I'm writing a
> recipe to spawn a new server instance and massage it into a fresh,
> clean, staging instance.  My recipes all set, except one thing: EC2
> provides a dynamic, unpredictable server name (something like
> ec2-67-202-12-42.z-1.compute-1.amazonaws.com).  I'd like to connect to
> this machine thru capistrano (and give it a better dns name, amongst
> other things) -- but how?
> 
> Roles apparently cannot be set within a task dynamically at runtime --
> this message told me so: "/usr/local/lib/ruby/gems/1.8/gems/
> capistrano-2.0.0/lib/capistrano/configuration/namespaces.rb:170:in
> `role': roles cannot be defined in a namespace (NotImplementedError)"
> 
> Has anyone encountered this problem?  If so, what solution do you
> suggest?
> 
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to