S
Steven Hansen
Hi,
I'm trying to clear up my understanding of how some of the Capistrano
connection stuff works. In the Capistrano manual, I found the following
"All |run| does is attempt to execute the given command on all
associated remote hosts. (We’ll talk more later about the available
helper methods, of which |run| is the most commonly used.) This means
that as soon as run is invoked, Capistrano inspects the current task and
determines what roles are active, and then determines which servers
those roles map to. If no connection has been made a server yet, the
connection is established and cached, and then the command is executed
in parallel. /This means that no connections are made to the remote
hosts until they are actually needed."/
I'm a bit confused about what it means to "cache" the connection. Let's
say I have the following tasks:
---------------------------------------------------------------------
task :wrapper do
show_env
set_gem_home
show_env
end
task :show_env do
run 'env'
end
task :set_gem_home do
run 'export GEM_HOME=/path/to/ruby/gems'
end
----------------------------------------------------------------------
What I'm seeing--when I run the :wrapper task--is that on the second
call to :show_env GEM_HOME is not set on the remote machine's
environment. If the connection is being cached, after the first call to
:set_gem_home wouldn't GEM_HOME be set for all subsequent tasks for that
machine?
I realize that the easiest way to set something like GEM_HOME is to
configure it in a .ssh/environment file. However, our sys admins have
disabled the [PermitUserEnvironment] option in the sshd_config file. As
things stand right now, I have to prepend all commands like this [export
GEM_HOME=/path/to/ruby/gems && gem install super_gem]. I'd like to avoid
this if possible.
Regards,
Steven
I'm trying to clear up my understanding of how some of the Capistrano
connection stuff works. In the Capistrano manual, I found the following
"All |run| does is attempt to execute the given command on all
associated remote hosts. (We’ll talk more later about the available
helper methods, of which |run| is the most commonly used.) This means
that as soon as run is invoked, Capistrano inspects the current task and
determines what roles are active, and then determines which servers
those roles map to. If no connection has been made a server yet, the
connection is established and cached, and then the command is executed
in parallel. /This means that no connections are made to the remote
hosts until they are actually needed."/
I'm a bit confused about what it means to "cache" the connection. Let's
say I have the following tasks:
---------------------------------------------------------------------
task :wrapper do
show_env
set_gem_home
show_env
end
task :show_env do
run 'env'
end
task :set_gem_home do
run 'export GEM_HOME=/path/to/ruby/gems'
end
----------------------------------------------------------------------
What I'm seeing--when I run the :wrapper task--is that on the second
call to :show_env GEM_HOME is not set on the remote machine's
environment. If the connection is being cached, after the first call to
:set_gem_home wouldn't GEM_HOME be set for all subsequent tasks for that
machine?
I realize that the easiest way to set something like GEM_HOME is to
configure it in a .ssh/environment file. However, our sys admins have
disabled the [PermitUserEnvironment] option in the sshd_config file. As
things stand right now, I have to prepend all commands like this [export
GEM_HOME=/path/to/ruby/gems && gem install super_gem]. I'd like to avoid
this if possible.
Regards,
Steven