I have upgraded to Cap2, and what I mention below

    run "echo \"port = #{host_to_port_map[$CAPISTRANO:HOST$]}\""

is *not* possible. $CAPISTRANO:HOST$ is treated simply as a
placeholder. It is not evaluated (it is simply substituted), so it
cannot be used in expressions like that above.

It seems that it would not be a difficult change to make Capistrano
evaluate the string as it is sent to each server -- on the Thread that
interacts with that server, rather than evaluate it once and send an
identical string to each Server?? If Cap did this, then we could apply
variation like this;

    run "start.sh -p #{host_to_port_map[$CAPISTRANO:HOST$]} -t
#{host_to_types_map[$CAPISTRANO:HOST$]}"

The alternative; to essentially put the info onto the server itself is
much less satisfactory. It doesn't yield a very flexible or generic
system. It would be better to read a YAML file with the server-
specific properties in it and adjust the run commands on a server-by-
server. E.g.

# -------------------
dev_test:
 node:
  -
     machine: 10.1.1.1
     types: [X, Y, Z]
     port: 11111
  -
     machine: 10.1.1.2
     types: [A, B, C]
     port: 21111
 manager:
  -
     machine: 10.1.1.3
     types: [X, Y]
     port: 31111
  -
     machine: 10.1.1.4
     types: [Z, A]
     port: 41111
   -
     machine: 10.1.1.5
     types: [B, C]
     port: 41111

On May 16, 11:17 pm, Chris Berry <[EMAIL PROTECTED]> wrote:
> Greetings,
> I would like to implement a run method within a task that is slightly
> different for its different servers. It is my impression that in
> Cap1.4 that this is not really possible?? In essence, the command
> string is fixed in the Actor (for all servers) and passed to the
> remote server as a "constant". E.g. run "echo #{deploy_to}" is sent to
> every remote server fully expanded as "echo /usr/local/foo", and there
> is no way to apply any server-by-server variation to the expansion. Is
> this correct??
>
> But in Cap2, it sounds like we can use $CAPISTRANO:HOST$ in the
> command expansion. So assuming that I have set a variable in my
> CapFile as, say, :host_to_port_map. Then could I use it in my run
> command as, say, run "echo \"port = #{host_to_port_map[$CAPISTRANO:HOST
> $]}\"" ?? This way I could apply at least some variation. It is still
> fully expanded before it is passed to the servers, but allows for some
> server-by-server variation.
>
> Thanks,
> -- Chris
>
> BTW: I know that I can just try this in Cap2, and figure it out. But
> am hoping to get some idea of whether I have a hope of succeeding
> before I convert my Cap1.4 project to Cap2. TIA


--~--~---------~--~----~------------~-------~--~----~
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