0

I am trying to upgrade my setup to v3 and am encountering an issue that I am finding trouble to debug. I use vagrant to test a staging environment for my very small app. Here is what my config/deploy/staging.rb file looks like:

set :user, "vagrant"
set :stage, :staging
set :ssh_options, {
 keys: %w(~/.vagrant.d/insecure_private_key),
 forward_agent: true
}
role :all, "192.168.33.101", primary: true

set :domain_name, "domain.local"

Here is my deploy:setup command for testing:

namespace :deploy do

  desc 'Setup the application (NO-OP Hook)'
  task :setup do
    on roles(:app) do
      execute :echo, :uptime
    end
  end

end

When trying do anything, even just getting uptime, this is the error I get:

$ cap staging deploy:setup --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy:setup (first_time)
** Execute deploy:setup
 INFO [5cf8fd6d] Running /usr/bin/env echo uptime on 192.168.33.101
 cap aborted!
 Net::SSH::AuthenticationFailed
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:156:in `ssh'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:109:in `block in _execute'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `tap'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:106:in `_execute'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:54:in `execute'
 /Users/mbridges/code/github.com/mattdbridges/cornerstone/config/deploy.rb:24:in `block (3 levels) in <top (required)>'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
 /Users/mbridges/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
 Tasks: TOP => deploy:setup

I was able to authenticate just fine prior to the upgrade. Any ideas?

1 Answer 1

3

As it turns out, it has to do with the Vagrant IP address and port configuration.

A simple change

# Old
role :all, "192.168.33.101", primary: true

# New
server "vagrant@localhost:2222", roles: %w[web app db], primary: true

This solves the problem, at least for me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.