connection failed - how do I get more verbose debugging?

6,285 views
Skip to first unread message

cnk

unread,
Jun 25, 2008, 8:07:18 PM6/25/08
to Capistrano
I am trying to set up Capistrano deployment of a rails app but am
stuck at the first step.

$ cap -d deploy:setup
* executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /rails/
styleguide..... list of directories

Execute ([Yes], No, Abort) ? |y| y
y
servers: ["xxx.yyy"]
connection failed for: xxx.yyy (NoMethodError: private method `split'
called for nil:NilClass)

I suspect this is something about sshing into the server - but given
the output with 'cap -d' it might be not having something set up for a
sudo password.

My network topology is a little odd. I am sitting at a Mac which
contains my ssh keys and runs ssh-agent to managed my authentication
to other servers. I then ssh to my main development server (RHEL4) and
try to run cap there to deploy to another linux box which is on the
other side of a load balancer. I can log into the eventual production
server from both the mac and my dev server w/o typing a password. So I
think I have all of my keys and agents taken care of. But I probably
don't have something set up correctly in my deploy.rb file:

set :user, 'cnk'
set :ssh_options, { :forward_agent => true, :port => 2202 }

role :app, "xxx.yyy"

Relevant version info:

capistrano (2.4.0)
net-scp (1.0.1)
net-sftp (2.0.1)
net-ssh (2.0.2)
net-ssh-gateway (1.0.0)

Anyway to get more debug info (for example tell capistrano to use 'ssh
--v')?

cnk

unread,
Jun 26, 2008, 8:58:47 PM6/26/08
to Capistrano
I would still love some debugging hints - blog post references??

Anyway I did figure out a way to try to break this down to simpler
tests.
Instead of trying to do a Rails deploy from my dev server, I tried
just invoking
a command.

cap invoke COMMAND='uname -a'

If I run it from my Mac desktop, I get the right answers from both my
dev server
and from my production server. But I still can't ssh to my dev server
and then
deploy to production from there.

My network diagram is a bit like:
a
Mac --- Dev
| |
c \ / b
\ /
LB ---- Prod

I can invoke cap commands over routes a and c. But what I really want
to do is ssh
into dev (via a) and then run capistrano over route b. My ssh keys are
on the Mac and
I am running ssh-agent in my terminal. I can ssh over all 3 routes a,
b, and c without
having to type extra ssh options or being asked to type my password.
So why can't I
run capistrano tasks from Dev (over route b)? My shell is fine, but I
appear to need to
give capistrano more information some how. I did try
adding :forward_agent => true to
my :ssh_options hash but that doesn't seem to help.

cnk

unread,
Jun 26, 2008, 10:07:42 PM6/26/08
to Capistrano
I asked for some help on IRC and was told that cap probably can't use
ssh-agent forwarded keys. So I tried changing this to use password. So
my stripped down Capfile now looks like:

set :user, 'cnk'
set :password, "mypass"
set :ssh_options, { :port => 2202 }

role :app, "xxx.yyy"

I tried getting a new terminal what did not know anything about ssh-
agent and my keys and then logging in using a password to get to dev.
I can ssh from dev -> production using the password in my Capfile. But
cap can't. I get the same error:

cap invoke COMMAND='uname -a'
* executing `invoke'
* executing "uname -a"
servers: ["xxx.yyy"]
connection failed for: xxx.yyy (NoMethodError: private method `split'
called for nil:NilClass)

Is there anyway to get capistrano to use ssh -v or throw a backtrace
so I can debug this? I tried aliasing ssh to ssh -v in my shell but
cap didn't pick it up. Does cap do something explicit to prevent that?
My first guess was it was a shell vs subshell issue, but no, I still
have ssh -v in my subshells.
Message has been deleted

Jamis Buck

unread,
Jun 26, 2008, 11:30:15 PM6/26/08
to capis...@googlegroups.com
Well, capistrano does support agent forwarding, so I don't know why
that wouldn't be working for you. You shouldn't even need to set
the :forward_agent key, since you want cap to consume from the
forwarded agent, not act as a conduit for it.

As for that unfortunate exception...there isn't any option for asking
for a better stack trace, though there ought to be. You'll probably
need to grep through the code for "connection failed for" and then
determine how to get the stack trace for the exception in question. If
you figure it out, please let me know, since this is definitely
something that cap should handle more gracefully.

- Jamis

On Jun 26, 2008, at 8:08 PM, cnk wrote:

>
> I asked for some help on IRC and was told that cap probably can't use
> ssh-agent forwarded keys. So I tried changing this to use password. So
> my stripped down Capfile now looks like:
>
> set :user, 'cnk'
> set :password, "mypass"

> set :ssh_options, { :port => 2202 }
>
> role :app, "xxx.yyy"
>


> I tried getting a new terminal what did not know anything about ssh-
> agent and my keys and then logging in using a password to get to dev.
> I can ssh from dev -> production using the password in my Capfile. But
> cap can't. I get the same error:
>

> cap invoke COMMAND='uname -a'

> * executing `invoke'
> * executing "uname -a"

> servers: ["xxx.yyy"]
> connection failed for: xxx.yyy (NoMethodError: private method `split'
> called for nil:NilClass)
>

cnk

unread,
Jun 27, 2008, 8:53:10 PM6/27/08
to Capistrano
I needed to upgrade my ruby install anyway. Since I want to run
Passenger, I installed Enterprise Ruby and today's new gem, capistrano
2.4.2. And suddenly I can use capistrano to run 'uname -a' on my
production server from my dev server just fine. It even uses my
forwarded ssh-keys! *does a happy dance*

Now all I need to do is figure out how to use capistrano for deploying
rails.
Reply all
Reply to author
Forward
0 new messages