All threads / Error when running in Test Env
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Error when running in Test Env

geekdie asked in Rails

Hi peeps,

I setup linux virtual machine in Azure, I was following this guide https://gorails.com/deploy/ubuntu/14.04

I want my VM as my test environment, however when I run 'cap test deploy' this what I get

test01@test01:~/IBEX-ShiftShark$ cap test deploy --trace
** Invoke test (first_time)
** Execute test
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG [f011606c] Running /usr/share/rvm/bin/rvm version as test01@13.76.1.66
DEBUG [f011606c] Command: /usr/share/rvm/bin/rvm version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as test01@13.76.1.66: Au thentication failed for user test01@13.76.1.66
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/runner s/parallel.rb:16:in rescue in block (2 levels) in execute'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/runner s/parallel.rb:12:in
block (2 levels) in execute'

Caused by:
Net::SSH::AuthenticationFailed: Authentication failed for user test01@13.76.1.66
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/net-ssh-3.0.1/lib/net/ssh.rb:2 39:in start'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/connection_pool.rb:50:in
call'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/connection_pool.rb:50:in create_new_entry'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/connection_pool.rb:22:in
checkout'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:187:in with_ssh'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:137:in
block in _execute'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:133:in tap'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:133:in
_execute'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:77:in capture'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/capistrano-rvm-0.1.2/lib/capis trano/tasks/rvm.rake:9:in
block (3 levels) in '
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:54:in instance_exec'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/backen ds/netssh.rb:54:in
run'
/home/test01/.rvm/gems/ruby-2.2.1@shiftshark/gems/sshkit-1.7.1/lib/sshkit/runner s/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rvm:check
test01@test01:~/IBEX-ShiftShark$

#My Deploy File

lock '3.4.0'

set :application, 'IBEX-ShiftShark'
set :repo_url, 'git@gitlab.com:bossj/IBEX-ShiftShark.git'
set :rollbar_token, 'a9f7527095e9410f97ae87d1eeac80c4'
set :rpush_pid, -> { File.join(shared_path, 'tmp', 'pids', 'rpush.pid') }

set :delayed_job_server_role, :app
set :delayed_job_args, '-n 2'

set :deploy_to, '/home/test01/IBEX-ShiftShark'

Default value for :linked_files is []

set :linked_files, %w[config/database.yml]
set :linked_dirs, %w[log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system]

Default branch is :master

ask :branch, proc { git rev-parse --abbrev-ref HEAD.chomp }.call

set :rvm_ruby_version, '2.2.1' # rvm gemset to use on the server
set :keep_releases, 5

namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :mkdir, '-p', "#{release_path}/tmp"
execute :touch, release_path.join('tmp/restart.txt')
end
end

after :publishing, :restart
after :finishing, 'deploy:cleanup'
end

after 'deploy:published', 'restart' do
invoke 'delayed_job:restart'
end

#config/deploy/test.rb

server '13.76.1.66', user: 'test01', roles: %w[web app db]
$LOAD_PATH.unshift(File.expand_path('./lib', ENV['rvm_path']))
set :rvm_custom_path, '/usr/share/rvm'
set :stage, :test
set :deploy_to, "/home/test01/#{fetch(:application)}/test/"
set :scm, :gitcopy

after 'deploy:finished', :restart_rpush do
on roles(:web) do
within release_path do
if test "[ -f #{fetch(:rpush_pid)} ]"
execute :bundle, :exec, 'rpush stop -e test'
end

  execute :bundle, :exec, 'rpush start -e test'
end

end
end

namespace :delayed do
desc 'Restart Delayed Job'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute! :sudo, 'service delayed_job restart'
end
end
end

So it says it can't authenticate:

SSHKit::Runner::ExecuteError: Exception while executing as test01@13.76.1.66: Au thentication failed for user test01@13.76.1.66

You'll want to make sure that your username, IP, and password / ssh key are correct. Sometimes you have to run "ssh-add -K" on a mac to add your ssh keys to the agent so that it uses the right key without having to manually specify it.

Whatever the issue is, it's just a misconfigured authentication somewhere.

@Chris Oliver

I think I missed the SSH setup something from your guide.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 54,919+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.