Is there a "from the beginning" page / tutorial for capistrano 3 like there is for capistrano 2?

1,219 views
Skip to first unread message

Vell

unread,
Dec 8, 2013, 2:56:49 PM12/8/13
to capis...@googlegroups.com
Versions:
  • Ruby 2.0.0-p247
  • Capistrano 3.0.1
  • Rake / Rails / etc  (unsure about this question. its a simple ruby application)
Platform:
  • Working on.... Mac OS X 10.9
  • Deploying to... Mac OS X 10.7
Logs:
  • I don't have any logs as of yet
Files:
  • Capfile
  • deploy.rb
  • Stage files (production.rb, staging.rb)
I have used capistrano 2 to deploy rails apps. I have not had to do that in a long time. I am trying to deploy a simple ruby application that I have created using the GLI gem but I can't seem to get a handle on the changes from capistrano 2 to capistrano 3. What happened me with capistrano 2 when I first started using it was this page on the capistrano github wiki https://github.com/capistrano/capistrano/wiki/2.x-from-the-beginning . Is there a page like this for capistrano 3? Something detailed and step by step that will help me understand things as I go along?

Lee Hambley

unread,
Dec 8, 2013, 4:01:11 PM12/8/13
to capis...@googlegroups.com
Lots of stuff on capistranorb.com!
--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/07aa0218-f85d-469a-9f60-2544a7465401%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


--
Lee Hambley
--

Vell

unread,
Dec 8, 2013, 4:59:43 PM12/8/13
to capis...@googlegroups.com
I looked at the readme and the http://www.capistranorb.com/documentation/getting-started/preparing-your-application. Its a lot of explaining but nothing that explains what the bare minimum is for deploying a ruby application. For instance, my application doesn't require the :web or :db part of the production application. So while there is "lots of stuff" there, there isn't something like the from beginning page that walks you through each part of the setup step by step to understand what your doing and why your doing it. Well at least not that I have seen.

Now I just need to understand why I am getting the following:

afrosamurai:sync[capistrano]$ bundle exec cap production deploy
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
Password:**********
DEBUG
Uploading /tmp/git-ssh.sh 0.0%
 INFO
Uploading /tmp/git-ssh.sh 100.0%
 INFO
[73e91495] Running /usr/bin/env chmod +x /tmp/git-ssh.sh on enterprise.domain.com
DEBUG
[73e91495] Command: /usr/bin/env chmod +x /tmp/git-ssh.sh
 INFO
[73e91495] Finished in 0.347 seconds with exit status 0 (successful).
cap aborted
!
administrator
/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:156:in `
ssh'
/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:68:in `upload!'

/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.0/lib/capistrano/tasks/git.rake:11:in `block (3 levels) in <top (required)>'
/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `
instance_exec'
/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/backends/netssh.rb:42:in `run'

/Users/vmcilwain/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.1.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)


On Sunday, December 8, 2013 4:01:11 PM UTC-5, Lee Hambley wrote:
Lots of stuff on capistranorb.com!

On Sunday, December 8, 2013, Vell wrote:
Versions:
  • Ruby 2.0.0-p247
  • Capistrano 3.0.1
  • Rake / Rails / etc  (unsure about this question. its a simple ruby application)
Platform:
  • Working on.... Mac OS X 10.9
  • Deploying to... Mac OS X 10.7
Logs:
  • I don't have any logs as of yet
Files:
  • Capfile
  • deploy.rb
  • Stage files (production.rb, staging.rb)
I have used capistrano 2 to deploy rails apps. I have not had to do that in a long time. I am trying to deploy a simple ruby application that I have created using the GLI gem but I can't seem to get a handle on the changes from capistrano 2 to capistrano 3. What happened me with capistrano 2 when I first started using it was this page on the capistrano github wiki https://github.com/capistrano/capistrano/wiki/2.x-from-the-beginning . Is there a page like this for capistrano 3? Something detailed and step by step that will help me understand things as I go along?

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+unsubscribe@googlegroups.com.

Lee Hambley

unread,
Dec 9, 2013, 3:59:15 AM12/9/13
to capis...@googlegroups.com
Hi Vell,

If you are familiar with Cap2, then the fundamentals of Cap3 didn't change.

Regarding your query, you look to be doing something non-standard (why is high line prompting for a password?) that's definitely nothing from us, and appears to be causing some problems.  It would appear that one of your servers isn't authenticating problems (I realise that's a little bit unclear, but it's clearly failing in `net/ssh.rb:215:in `start'`) 

I'd say that you need to make sure your SSH keys are working correctly before starting with Capistrano!

Good luck.

Vell

unread,
Dec 9, 2013, 11:38:08 AM12/9/13
to capis...@googlegroups.com
Thanks for the response Lee.

The server I am attempting to deploy to doesn't have an ssh-key on it that allows me to authenticate without a password. It is only one server that I am deploying to in this case (another OS X system). This is why I believe it prompted me for a password. I figured that if the other users that attempt to deploy, don’t know the password to the server then I’m fairly safe. It keeps me from having the task of adding users to the authorized keys file on that server. However, there aren’t that many users, so if I have to do it I will.

Right now here is what I have in my files. Sorry for the entries being ambiguous.

deploy.rb

set :application, 'my_sync'
set :repo_url, 'http://gitserv.domain.com/dba/my_sync'


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


set :deploy_to, '/users/administrator/scripts/my_sync'
set :scm, :git


# set :format, :pretty
# set :log_level, :debug
# set :pty, true


# set :linked_files, %w{config/database.yml}
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}


# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 3


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

production.rb

set :stage, :production

role
:app, %w{administrator@server.domain.com}

server
'server.domain.com', user: 'administrator', roles: %w{app} #, my_property: :my_value

I figured this was pretty much all I needed.

Lee Hambley

unread,
Dec 9, 2013, 11:43:03 AM12/9/13
to capistrano
Looks like `on roles(:web), in: :groups, limit: 3, wait: 10 do` is a problem, as you haven't put any servers in the `web` role. (I assume, having never tried it that the server() command, overwrites the role() command, you are meant to take one, or the other not both!)

If you don't need an SSH key, or a password, I have no idea what'll happen. From the code you posted where the highlight password prompt is coming from.

I wish I could be more help.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/e1768e72-d141-4165-99c4-099ce0c2e858%40googlegroups.com.

Vell

unread,
Dec 9, 2013, 11:46:16 AM12/9/13
to capis...@googlegroups.com
Sorry I failed to mention the command I used.

I ran the command cap production deploy:check.

I just ran it again and got the following:

$: cap production deploy:check

Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
 
Password:*******


DEBUG
Uploading /tmp/git-ssh.sh 0.0%

 INFO
Uploading /tmp/git-ssh.sh 100.0%

 INFO
[d53988aa] Running /usr/bin/env chmod +x /tmp/git-ssh.sh on server.domain.com

DEBUG
[d53988aa] Command: /usr/bin/env chmod +x /tmp/git-ssh.sh

 INFO
[d53988aa] Finished in 0.268 seconds with exit status 0 (successful).

DEBUG
[86656372] Running /usr/bin/env git ls-remote http://gitserv.domain.com/dba/my_sync on server.opnet.com

DEBUG
[86656372] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/git-ssh.sh /usr/bin/env git ls-remote http://gitserv.domain.com/dba/my_sync )

Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.

Password:*****


DEBUG
[86656372] fatal: http://gitserv.domain.com/dba/my_sync/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?

DEBUG
[86656372] Finished in 5.518 seconds with exit status 128 (failed).


So this gives me a little bit more data to see whats going on I think.

Vell

unread,
Dec 9, 2013, 11:53:18 AM12/9/13
to capis...@googlegroups.com
Hmm it is possible that I don't either code blocks in the deploy name space since all I care about is getting the code to the server and not to run any tasks aside from that. It looks like my issue now is with running a git command on the remote server which I am unsure how to address at the moment and will have to look into it.

Lee Hambley

unread,
Dec 9, 2013, 11:59:46 AM12/9/13
to capistrano
Looking at your code, I'd assume the highlight password prompt is coming from Net::SSH itself, I have never seen that before, since I always use keys.

https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md is a decent reference for "just running SSH commands" … if you don't need all the versioning/rollback/plugin hooks of Capistrano, just use Rake and SSHKit, see the article on my blog about doing that: http://lee.hambley.name/2013/06/11/using-capistrano-v3-with-chef.html

Vell

unread,
Dec 9, 2013, 12:02:03 PM12/9/13
to capis...@googlegroups.com
I actually like the versioning and rolling back but its not a must to have. I will take a look at your blog and see if that fits a little bit better.

Thanks,

Lee Hambley

unread,
Dec 9, 2013, 12:03:53 PM12/9/13
to capistrano
My blog doesn't specifically refer to Git, it builds a tarball from a local working copy, and conditionally uploads that. 

I'm surprised that you are having such problems. You might also try the password format like `user:password@host` - which should spare you the prompt, at least. (Authenticating with a password is also in the SSHKit README and EXAMPLES files.

Lee Hambley

unread,
Dec 9, 2013, 12:05:11 PM12/9/13
to capis...@googlegroups.com
https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md#set-a-password-for-a-host (obviously, once it's working, you can go back to prompting for a password)

Vell

unread,
Dec 9, 2013, 12:11:28 PM12/9/13
to capis...@googlegroups.com
Actually, my dialog with you has helped quite a bit. I was very close and you helped me to get over the hump.

I did decide to install my public key on the authorized keys on the server. Its better then being prompted for my password 4 times during the actual deployment. Once I changed the repo url from http:// to git:// that eliminated the error I was getting about running git update-info on the git server. As for the deploy name space blocks, I just commented out the contents of each block since I don't need them and I was able to deploy without any issues. The remote server has everything it should and I am in the clear.

I appreciate you talking me through it.

Lee Hambley

unread,
Dec 9, 2013, 12:18:17 PM12/9/13
to capistrano
Great, I'm chuffed you got it working in the end. Keys are the answer, really :-D or the password trick (which is intentionally a bit weird).
Regarding those empty block things, yeah, if you don't need 'em, just comment them out. I thought you should be able to remove them completely, but then you might get missing task errors. If that happens you can just do:

namespace :whatever do
  task :a
  task :b
end

(define two noop tasks in namespace :whatever) ... it might be easier on the eyes?

Vell

unread,
Dec 9, 2013, 3:01:01 PM12/9/13
to capis...@googlegroups.com
I actually do have one more question. I see that we can deploy from a branch but is there a way to set a tag for deployment?

I tried using set :tag, "x.x.x" but I can't tell if that is a viable option.

Lee Hambley

unread,
Dec 9, 2013, 3:29:13 PM12/9/13
to capistrano

In Git branches, tags, refs are all the same thing!

Sent from my Nexus 4.

Reply all
Reply to author
Forward
0 new messages