Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano::NoMatchingServersError on deploy:update_code

I have a capistrano deploy script that works on my windows local machine but a coworker on a mac is hitting a deploy error. It's actually just his laptop since it works on other macs as well, so I'm wondering if there is some capistrano cache that needs to be cleared? The error is...

* Compressing /var/folders/kv/g4k3rk815sd14948vzf1lhg40000gn/T/20131203013325 to /var/folders/kv/g4k3rk815sd14948vzf1lhg40000gn/T/20131203013325.tar.gz
    executing locally: tar czf 20131203013325.tar.gz 20131203013325
    command finished in 114ms
*** [deploy:update_code] rolling back
 ** [deploy:update_code] exception while rolling back: Capistrano::NoMatchingServersError, `deploy:update_code' is only run for servers matching {:except=>{:no_release=>true}}, but no servers matched `deploy:update_code' is only run for servers matching {:except=>{:no_release=>true}}, but no servers matched

My deploy.rb (the important parts) are as follows...

set :application, "app"

task :prod do 
  role :app, "10.1.40.123"
  role :web, "10.1.40.123"
  role :db,  "10.1.40.123", :primary => true
  set :user, "root"
  set :password, "password"
  set :rails_env, "production"
  set :use_sudo, false
  load 'deploy/assets' # this line runs rake assets precompile
  set :os, 'ubuntu'
  default_environment["LD_LIBRARY_PATH"] = '/opt/oracle/instantclient_12_1'
end 
set :repository, "ssh://[email protected]/opt/git/hub/app.git"
set :deploy_to, "/srv/www/#{application}"
set :deploy_via, :copy
set :keep_releases, 5

set :scm, "git"
set :branch, "master"

after 'deploy:update_code', 'deploy:symlink_shared', "deploy:migrate","deploy:restart"

He is able to deploy other apps using capistrano, we are using capistrano 2.

like image 711
HelloWorld Avatar asked Nov 11 '22 17:11

HelloWorld


1 Answers

Seems like you are trying to deploy to multiple stages with a custom task instead of using multistage extension. This way when you are running cap prod you are not actually deploying, and when running cap deploy you are not setting the roles, which causes the error in question. So, the solution would be to rewrite your deploy.rb to something like the following:

set :stages, %w(prod staging)
set :default_stage, "staging"
require 'capistrano/ext/multistage'

set :application, "app"
set :repository, "ssh://[email protected]/opt/git/hub/app.git"
set :deploy_to, "/srv/www/#{application}"
set :deploy_via, :copy
set :keep_releases, 5

set :scm, "git"
set :branch, "master"

after 'deploy:update_code', 'deploy:symlink_shared', "deploy:migrate","deploy:restart"

Then, in your config/deploy/prod.rb you should have your prod-related setup:

role :app, "10.1.40.123"
role :web, "10.1.40.123"
role :db,  "10.1.40.123", :primary => true
set :user, "root"
set :password, "password"
set :rails_env, "production"
set :use_sudo, false
load 'deploy/assets' # this line runs rake assets precompile
set :os, 'ubuntu'
default_environment["LD_LIBRARY_PATH"] = '/opt/oracle/instantclient_12_1'

This way you'll be able to deploy to production with cap prod deploy (or with cap deploy too if you change set :default_stage, "staging" to set :default_stage, "prod").

like image 188
bredikhin Avatar answered Nov 15 '22 05:11

bredikhin