Echographia

making things better, making better things

Tuesday, July 29, 2008

Capistrano deployment from an internal svn server

A few months ago, I had to move a project I was working on to a new production environment, and I had some trouble getting Capistrano to deploy our code. The problem was basically this:

I was in one closed network, the deployment machine was in another, and I could use ssh to connect to the deployment machine.  But Capistrano wanted to connect back from the deployment machine to our Subversion repository, and it just couldn’t get there.

What I ended up doing was making Capistrano set up an ssh tunnel for Subversion, so that the remote machine could make an svn connection to itself, which forwarded back through my ssh session to the svn server in our development network.  Here’s the code (fill in your own hostname):

1
2
3
4
5
6
7
8
9
10
11
12
namespace :deploy do
  task :before_update_code do
    run 'echo Creating SSH tunnel for Subversion....' do |channel, stream, data|
      ssh = channel.connection
      ssh.forward.remote(
        3690, 'svnserver.your.intra.net',
        3690, '127.0.0.1'
      )
      ssh.loop { !ssh.forward.active_remotes.include?([3690, '127.0.0.1']) }
    end
  end
end

Disclaimers: 1. There’s probably an easier way to do this. 2. I think this was on Capistrano 2.0, and I haven’t tested it on a newer version. 3. Most importantly, I have no idea what the security implications of opening this SSH tunnel are. Use at your own risk.

posted by erik at 1:11 am  

1 Comment

  1. [...] public links >> capistrano Capistrano deployment from svn via ssh First saved by superjayjay | 10 days ago Deploying Drupal with Capistrano First saved by [...]

    Pingback by Recent Faves Tagged With "capistrano" : MyNetFaves — March 9, 2009 @ 2:20 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress