Reputation: 5260
I am struggling with upgrading capistrano v2 to v3 for 5 days.I am trying to deploy from my local machine to ec2 instance development environment. I can't move further. My trace is here
$cap development deploy:check
INFO [429e612c] Running /usr/bin/env mkdir -p /tmp/my_app_name/ on 70.22.320.14
DEBUG [429e612c] Command: ( RVM_BIN_PATH=~/.rvm/bin /usr/bin/env mkdir -p /tmp/my_app_name/ )
INFO [429e612c] Finished in 6.208 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/my_app_name/git-ssh.sh 0.0%
INFO Uploading /tmp/my_app_name/git-ssh.sh 100.0%
INFO [c3a41f2e] Running /usr/bin/env chmod +x /tmp/my_app_name/git-ssh.sh on 70.22.320.14
DEBUG [c3a41f2e] Command: ( RVM_BIN_PATH=~/.rvm/bin /usr/bin/env chmod +x /tmp/my_app_name/git-ssh.sh )
INFO [c3a41f2e] Finished in 0.720 seconds with exit status 0 (successful).
DEBUG [c5891dcc] Running /usr/bin/env git ls-remote [email protected]:example/webapp.git
on 70.22.320.14
DEBUG [c5891dcc] Command: ( RVM_BIN_PATH=~/.rvm/bin GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app_name/git-ssh.sh /usr/bin/env git ls-remote [email protected]:example/webapp.git
DEBUG [c5891dcc] /usr/bin/env:
DEBUG [c5891dcc] git
DEBUG [c5891dcc] : No such file or directory
DEBUG [c5891dcc]
DEBUG [c5891dcc] Finished in 0.664 seconds with exit status 127 (failed).
config/deploy.rb
set :application, 'my_app_name'
set :repo_url, '.'
set :branch, 'master'
set :scm, :git
set :deploy_to, "/home/ec2-user/capistrano-3/}"
set :ssh_options, {:keys => ["#{ENV['HOME']}/.ssh/my_pem.pem"], :forward_agent =>true}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, '2.0.0-p353'
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
set :whenever_command, "bundle exec whenever"
set :git_shallow_clone, 1
set :deploy_via, :copy
set :log_level, :debug
set :pty, true
set :linked_files, %w{config/database.yml}
SSHKit.config.command_map[:rake] = "bundle exec rake"
SSHKit.config.command_map[:rails] = "bundle exec rails"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
after :finishing, 'deploy:cleanup'
end
config/deploy/development.rb
set :stage, :development
role :app, %w{[email protected]}
role :web, %w{[email protected]}
role :db, %w{[email protected]}
role :all, %w{[email protected]}
server '[email protected]', user: 'ec2-user', roles: %w{web app}
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
My problems:
My git path is not accepted
ssh key problems
git and ssh keys work with capistrano 2 for the same app I am deploying. Upgrading to capistrano v3 gives a bigger head-ache. What can I do consecutively. Kindly guide me through the correct steps
Upvotes: 1
Views: 2013
Reputation: 1861
I have spent some time struggling with capistrano3 and here are some hints, probably they can be useful:
1) Official manual capistranorb.com. There are tips about what you should do consecutively. Section about authentication and authorisation also helpful. There are some hints about ssh configuring on workstation and on server. I have followed on this guide and it helps me. Try to build your deploy.rb by following this guide from scratch.
Also helpful guides: guide1, guide2
2) Here is my Capfile. Notice rvm1/capistrano3 and capistrano3/unicorn. Very useful gems.
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano3/unicorn'
require 'rvm1/capistrano3'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
3) You can try the command:
ssh [email protected] -v
or
ssh [email protected] -v # from your EC2 server
to understand what happens when you try connect to your EC2 server. Probably the problem with pem key? Create .pub key and try to use it. Don't forget to add it to the ~/ssh/authorized_keys
cat id_rsa_aws.pub | ssh [email protected] "cat >>
/home/ubuntu/.ssh/authorized_keys"
configure your ssh-agent and don't forget to add in your ~/.bash_profile something like this:
eval $(ssh-agent)
ssh-add ~/.ssh/id_rsa_deploy_github
ssh-add ~/.ssh/id_rsa_digital_ocean
If you have problems with ssh, probably you should look at this ssh-guide
Also you can watch my app, where i am using capistrano3. Probably you can find there something for you: #project
P.s. On some VPS git is not installed, so it is good idea to check:
deployer@ec2***.amazonaws.com$ which git
if not found:
deployer@ec2***.amazonaws.com$ sudo apt-get install git
Upvotes: 4