Taking it further... you can also then dynamically name your tasks
(which is slightly crazy, but hey...)

desc "Just spitting out some IPs from the command line"
task (ENV["TASK_NAME"] || :spit_addresses).to_sym do
   ENV["ADDRESSES"].split(",").each {|a| puts a }
end

That task will then be named whatever you pass in for TASK_NAME,
defaulting to :spit_addresses, e.g.:

cap funkytown TASK_NAME=funkytown ADDRESSES=10.0.0.1,10.0.0.2

I guess the point (since this doesn't directly answer your question)
is that you can load your arguments from the command line, and set/
change tasks/roles and their deps at runtime according to your needs
with a lil' Ruby.


On Jun 12, 12:56 pm, Mason Browne <[EMAIL PROTECTED]> wrote:
> You can load/access arguments via environmental variables. For  
> example, if you wanted to pass in some IP addresses:
>
> desc "Just spitting out some IPs from the command line"
> task :spit_addresses do
>    ENV["ADDRESSES"].split(",").each {|a| puts a }
> end
>
> and then call it with:
>
> cap spit_addresses ADDRESSES=10.0.0.1,10.0.0.2,10.0.0.3
>
> it would puts:
>
> 10.0.0.1
> 10.0.0.2
> 10.0.0.3
>
> Hope that helps.
>
> On Jun 12, 2008, at 11:56 AM, shadowbq wrote:
>
>
>
> > Is there any way to override the role members from the command line?
>
> > ex.. (of course is wrong)
> > cap uname_dbservers uname_webservers dbservers="10.0.0.1"
>
> > ==== capfile ===
> > [..snip..]
> > role :dbservers = "10.0.0.2"
> > role :webservers = "10.0.0.3"
>
> > desc "create rule link on sguild server"
> > task :uname_dbservers, :roles => :dbservers do
> >  sudo "uname -a"
> > end
>
> > desc "set dns server"
> > task :whoami_webserver, :roles => :webservers do
> >     sudo "whoami"
> > end
>
> > ======
>
> > I wish that it would leave the webservers role alone and run on the
> > two servers 10.0.0.1 & 10.0.0.3.
>
> > NOTE: If I use HOSTS="10.0.0.1" it will run the two commands only on
> > the HOSTS only not the webservers role.
>
> > =======
>
> > Any dice ???
--~--~---------~--~----~------------~-------~--~----~
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