Webistrano/Capistrano problem with git

Posted by Jonathan

Recently I helped a friend debug a problem when deploying with Webistrano/Capistrano.

He was using a git repository and used SSH keys for authentication. Every time he tried to deploy he got this error:

 executing locally: "git ls-remote ssh://repo.example.com/git/myproject.git HEAD"
*** Could not save revision: Unable to resolve revision for 'HEAD' on repository 'ssh://repo.example.com/git/myproject.git'.

When running this command manually as the Webistrano user, everything worked fine.

We checked the usual suspects: the SSH key, the permissions on the SSH dirs/files, user, firewall & co. Everything seemed correct and worked when we ran the command by hand.

After a bit of tinkering I had the Eureka moment: the git command was not in $PATH when running under Passenger!

Git was installed and worked when we logged in as the Webistrano user. But when Passenger runs Webistrano it doesn't load all your shell config files. So if git is not in a standard location like /usr/bin or /bin Capistrano (which by this time will be called from Webistrano to do the actual deployment) will not find it.

I our case git was installed in /usr/local/bin and thus not in the default path. We ended up symlinking it to /usr/bin and everything worked like a charm.

I just committed a fix to Capistrano to make debugging such errors in the future easier. Capistrano will now check every local command it executes and see if it is in path. So with the latest version on github the error message would have looked like this:

 executing locally: "git ls-remote ssh://repo.example.com/git/myproject.git HEAD"
*** executable 'git' not present or not in $PATH on the local system!
*** Could not save revision: Unable to resolve revision for 'HEAD' on repository 'ssh://repo.example.com/git/myproject.git'.

So if you are running any shell commands under Passenger remember that it doesn't use a full login-shell.

Webistrano 1.4 released

Posted by Jonathan

I just released Webistrano 1.4. Webistrano is a tool for managing Capistrano deployments and offers a rich web UI. It lets you manage projects with their stages and keep track who deployed which version to which servers.

Webistrano 1.4 brings many new features that make deployment easier. The most prominent are:

  • Recipe versioning - recipes are now versioned so that you can keep track of changes
  • Project cloning - you can now create a template project and clone it over and over again
  • Array parameters - support for arrays as values for configuration parameters
  • CAS-auth support - Single Sign-On support by delegating authentication to a CAS server. See the documentation
  • Enhaced UI - nicer overviews of deployments and many small fixes
  • Cancel deployments - a running deployment can now be canceled by Webistrano. The running Capistrano instance will be killed so use this feature with care
  • Track deployed revisions - Webistrano will track which revision was deployed. This way you always know which version is running where
  • Updated packages - Rails 2.1 and Capistrano 2.5.0

Apart from that some smaller enhancements and fixes went into the 1.4 release. See the CHANGELOG for a complete list.

Further, there is now a Webistrano mailing list at GoogleGroups.

Go get Webistrano from the project homepage as a download or checkout the source:

Download: webistrano-1.4.zip (3.4 MB)

# Development version:

svn co http://labs.peritor.com/svn/webistrano/trunk

# Stable version:

svn co http://labs.peritor.com/svn/webistrano/branches/1.4

RailsConf Europe 2008

Posted by Jonathan

Day two of RailsConf Europe 2008 is over and so are my two sessions.

On tutorial day Mathias and I did a 4h workshop on deploying and monitoring Rails applications. The tutorial went really well, apart from the AirportExpress base station not coping with 100 laptops connecting to it. In the practical part we had a FreeBSD server with 40 virtual machines running and helped the audience deploy an example application with git or svn and Mongrel or mod_rails.

On day two I held my Security on Rails session where I go over the various attacks and countermeasures against Rails applications. This session was also well received and I hope I could educate people a bit about WebAppSecurity.

The slides are available as PDF here: Security on Rails (PDF) Deploying and Monitoring Rails (PDF)

Further, you can find both presentations at slideshare.

Security On Rails
View SlideShare presentation or Upload your own. (tags: ruby rubyonrails)


The slides are available as PDF here: Security on Rails (PDF) Deploying and Monitoring Rails (PDF)

If you attended one of my sessions, I encourage you to rate them at the conference site.

So far my expectations have been met and I've could catch up with a lot of people. I'm looking forward to day three of RailsConf Europe!

Webistrano 1.3 released

Posted by Jonathan

I'm proud to announce Webistrano 1.3!

Webistrano is a Web UI for managing Capistrano deployments. It lets you manage projects and their stages like test, production, and staging with different settings. Those stages can then be deployed with Capistrano through Webistrano.

The 1.3 adds several new shiny features to Webistrano that make deployment easier:

  • Better Git support through Capistrano 2.2
  • Support for Phusion Passenger / mod_rails
  • Ability to temporary disable hosts for a deployment
  • A command-line interface with script/deploy
  • A simple permission system

The complete changelog is available through the Webistrano project site.

One very often demanded feature is the ability to temporary disable a host for a deployment. This is helpful when you want to deploy a stage without changing the stage configuration even if one or more hosts are down:

Another scenario is when you want to execute a task only on a limited set of servers.

The script/deploy command is a nice little gem, especially useful if you want to script Webistrano:

$ ruby script/deploy 
Usage: deploy [options] project stage
    -h, --help                       This message
    -e, --environment=ENV            RAILS_ENV for Webistrano (default: production)
    -u, --username=NAME              Webistrano username to use (default: admin)
    -t, --task=NAME                  Capistrano task to invoke (default: deploy)
    -d, --description=TEXT           Deployment comment for Webistrano records

Further, Webistrano now offers built-in tasks for managing mod_rails deployments. It will override the default deploy tasks and ask for the necessary configuration entries so that using mod_rails becomes even easier.

Upgrading from previous releases is very easy, see the Upgrading wiki page.

Webistrano 1.3 can be downloaded here. Webistrano is BSD-licensed and the project site is open for everybody. Please see the project page for more documentation and screenshots. There are even some screencasts.

Webistrano 1.2 released

Posted by Jonathan

Webistrano 1.2 is out. You can get it at the Peritor Labs project page.

Version 1.2 brings the following changes and enhancements:

  • Fixes a bug in the execution of tasks with sudo
  • Highlight recipe syntax with the syntax gem
  • Include Capistrano 2.1.0 and git support
  • Add experimental support for ssh_keys and ssh_ports as normal configuration parameter (currently only one SSH key is supported)

Although Capistrano 2.1.0 is included, Webistrano will by default allocate a pty for each SSH command as the new Capistrano default of now doing so seems problematic on some hosts.

Further there where some minor fixes and UI enhancements. All available configuration parameter are now documented in the wiki.

Upgrading is done with a `RAILS_ENV=production rake db:migrate`, more information on how to upgrade can be found here.

With version 1.2 out of the door I will focus on bringing authorization to Webistrano so that deployment permissions can be tight to individual users and groups.

Get version 1.2 either from the download page or directly here: webistrano-1.2.zip

Capistrano and Webistrano configuration parameter overview

Posted by Jonathan

Capistrano (and thereby Webistrano) is very flexible and there are a lot of variables that can change its default behaviour.

Unfortunately there is no one public list of all parameter to tweak. As the question about all of those comes up every now and then I decided to create a probably incomplete list of all configuration parameter for Webistrano and Capistrano.

The list can be found on the Webistrano project page.

If you have any additions or corrections, please tell me or use the project page directly to submit corrections.

Capturing Output in Capistrano

Posted by Jonathan

A common question about Capistrano tasks is how to capture the output of a task. By default Capistrano will just execute your command and ignore any output.

But sometimes you want to capture and log the output. There is no easy command to do this right now, you have to use the SSH channels:

run "cat /etc/passwd " do |ch, stream, data|
  if stream == :err
    logger.debug "capured output on STDERR: #{data}"
  else # stream == :out
    logger.debug "capured output on STDOUT: #{data}"
  end
end

You can even send data back depending on the captured output:

run "mysql -u root my_database -p < /tmp/dump.sql" do |ch, stream, data|
  if data =~ /password:/
    ch.send_data(root_password)
  end
end

Using this technique you can store command output in the Webistrano log or just print it if you are using stock Capistrano.

Webistrano 1.1 released

Posted by Jonathan

Webistrano 1.1 is finally out. Webistrano is a Web UI for managing Capistrano deployments. It lets you manage projects and their stages like test, production, and staging with different settings.

It took a little longer because we got some feedback at Rails Conf Europe that we incorporated.

Further Webistrano now has its new home and own Trac/Wiki/Ticketsystem at the Peritor Labs. Peritor Labs is the place where we are going to release inhouse projects like Webistrano under the BSD license. At the moment there is only Webistrano but more will follow.

This means that the Subversion URL also changed. If you tracked Webistrano through svn, please switch to new URL:

svn switch --relocate http://webistrano.rubyforge.org/svn/trunk/ \
http://webistrano.rubyforge.org/svn/trunk http://labs.peritor.com/svn/webistrano/trunk

The major change in version 1.1 is a new shiny UI by the curtsy of Marcus Lamer.

Check out some new screenshots.

Further recipes are now associated to stages and not projects anymore so that different stages of a project can have different recipes. Webistrano now also set two variables inside recipes by default. Those two variables ( :webistrano_project and :webistrano_stage) are set to the project and stage name and can be used to do some decision making inside your recipes.

Upgrading from 1.0 is quite easy, just download the new version, copy your configuration files over and upgrade the database:

RAILS_ENV=production rake db:migrate

The roadmap for the next versions includes some basic monitoring capabilities and some form of permission management that lets you manage which user can deploy which projects and so on. The screencasts have not been updated yet but the content they provide is still valid, the only change is that recipes now belong to stages.

If you have any feedback, please comment here or use the Wiki.

Direct download link: webistrano-1.1.zip or at the Peritor Labs project page.

A preview of Webistrano 1.1

Posted by Jonathan

It's been two weeks since the public release of Webitrano . Webistrano was downloded nearly 500 times and I got a lot of feedback. People seem to like the concept and having a tool to manage Capistrano deployments through a Web UI.

A lot of people wanted to tie recipes not to projects but to stages, so Webistrano 1.1 will let you do that. Further 1.1 will interpolate strings in Capistrano variables correctly so that you can refer to other variables inside configuration entries.

Also more recent versions of needle/net-ssh will be included so that Webistrano will not blow up if you have newer versions installed.

Apart from this new functionality/bug-fixing the UI got some major enhancements and now looks very promising:



I hope to get 1.1 out of the door shortly after RailsConfEurope here in Berlin. If you are there and have any feedback, I would love to hear it.

Webistrano - A Web UI for managing Capistrano deployments

Posted by Jonathan

I'm happy to announce the release of Webistrano - a Web UI for managing Capistrano deployments.

Webistrano is an internal application that I developed at Peritor for the easy handling of Capistrano deployments. I often had situations where our designer updated some images and wanted to update/deploy our Rails project. Capistrano offers a nice command line interface for doing this but this is not the right tool for a designer, especially if you have a complicated multi-stage environment with production, staging and test settings.

Further we wanted to be able to keep track of who deployed what when to which servers.

This is where Webistrano enters the stage.

Webistrano

Webistrano is a Ruby on Rails application that manages projects with their different stages (like production or testing) and leverages Capistrano to handle the deployment part. This way it is very easy to handle multi-stage and multi-client situations and keep an eye on all deployments. It further includes a simple email alerting system so that you get pinged if somebody deploys to the production servers.

We are using Webistrano for quite some time now and it has proven stable for our needs. I am releasing it under the BSD license. The Subversion repository is located at Rubyforge.

On the project page you can find two screencasts that show you how to get Webistrano running and explain some advanced concepts.

Version 1.0 can be downloaded here:
Make sure to watch the screencasts:  

I presented Webistrano last month at the Berlin Ruby User Group (then under the name 'Webcap') and the feedback was quite positive. I'd love to hear your feedback and suggestions.

UPDATE:
There was a problem with the Mephisto comment system that resulted in all posted comment being posted to /dev/null. The problem is fixed now, please re-submit your comments.