CSC/ECE 517 Fall 2013/ch1 1w09 hs

From Expertiza_Wiki
Revision as of 04:34, 17 September 2013 by Hbhoomi (talk | contribs) (→‎Introduction)
Jump to navigation Jump to search

Code Deployment and Release Management with Rails

Code Deployment or Software Deployment and Release management with Ruby on Rails can be done using various tools such as Capistrano, Heroku, Mina, Vlad, Inploy etc. These automated tools are frameworks used to write and execute commands in parallel remote machines and thus ease the process of deployment and management of various applications.

Introduction

Deployment

Deployment is the process of transferring an application onto a production server to make it available for other users. This process involves various activities and transitions between them. Though the general guidelines for deployment remain the same, the specific requirements vary with each software system. Different deployment activities include release, install and activate, deactivate, adapt, update, built-in, version tracking, uninstall and retire.

Release Management

Release management is a software process which takes care of the development, testing, deployment and support stages of software releases. The start of release management happens in the development phase, where it requests for new features or changes in the existing. When the request is accepted, a new release is planned and designed. This design then enters the testing phase, where the release is built and tested until it is accepted. After the release is accepted as a candidate, it enters the deployment phase where it is implemented. Once deployed, the release is made available and sent to support phase for collection of bug reports. Once the support phase is done, the bugs and other issues lead to the requests for changes and the cycle is then repeated.

Deployment Process

Why Automate Deployment

Automation of a process is required when the manual process is more error prone. Also, for large real world applications, the manual process is very complex and time consuming. The incomplete documentation add to the drawbacks of a manual process. The components require the deployment to be done in a specific order to many environments. Manual process needs repetition of same procedure to each and every environment which leads to many errors and the process becomes costly.

Automation of deployment delivers applications faster and with fewer errors. The defined software deployment process can be applied across all environments consistently every time. With various automated application deployment platforms now readily available, manual deployments become a thing of the past.

Deployment Automation tools

Some of the automated tools that are widely used for the process of deployment with Ruby on Rails are

  • Capistrano
  • Heroku
  • Vlad

Lets look at each of them in turn.

Capistrano

Capistrano is a Ruby program that gives you a set of advanced tools to deploy web applications to your servers. With Capistrano it’s also possible to deploy to many machines at once. Capistrano offers many advanced options and can be used to deploy many kinds of applications.

It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workdflows.

Capistrano can be used to:

Reliably deploy web application to any number of machines simultaneously, in sequence or as a rolling set

  • To automate audits of any number of machines (checking login logs, enumerating uptimes, and/or applying security patches)
  • To script arbitrary workflows over SSH
  • To automate common tasks in software teams.
  • To drive infrastructure provisioning tools such as chef-solo, Ansible or similar.

Capistrano is also very scriptable, and can be integrated with any other Ruby software to form part of a larger too.

Installing Capistrano

General Usage

The following commands will clone Capistrano at the latest v3 revision, and will build the gem and install it locally.

$ gem install capistrano --pre --trust-policy HighSecurity

Or grab the bleeding edge head from:

$ git clone -b v3 https://github.com/capistrano/capistrano.git
$ cd capistrano
$ gem build *.gemspec
$ gem install *.gem

Signed Rubygems

As Capistrano is a signed gem, you should always be careful to use the --trust-policy flag when installing Gems, or since Bundler 1.3 you should use the same flag:

$ gem install capistrano --pre --trust-policy HighSecurity
$ bundle install --trust-policy HighSecurity

If you get a message that looks like:

ERROR:  While executing gem ... (Gem::Security::Exception)
unsigned gems are not allowed by the High Security policy

Then please complain to your Gem author, and have them start signing their Gems.

Usage in a Rails project

Add the following lines to the Gemfile to the :development group ideally.

group :development do
  gem 'capistrano-rails', '~> 0.0.7'
end

Heroku

Heroku is a cloud platform as a service (PaaS) supporting several programming languages. Heroku was acquired by Salesforce.com in 2010. Heroku, one of the first cloud platforms, has been in development since June 2007, when it supported only the Ruby programming language, but has since added support for Java, Node.js, Scala, Clojure and Python and (undocumented) PHP and Perl. The base operating system is Debian or, in the newest stack, the Debian-based Ubuntu.

Heroku lets you manage environment-specific configurations (such as credentials for backing services) separately from your source code for greater safety and portability. In Heroku, this data can be managed with config vars, which are made available to your running application as simple environment variables.

Heroku CLI

The Heroku CLI is used to manage Heroku apps from the command line.

Once installed, you'll have access to the heroku command from your command shell. Log in using the email address and password you used when creating your Heroku account:

$ heroku login
Enter your Heroku credentials.
Email: adam@example.com
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading SSH public key /Users/adam/.ssh/id_rsa.pub

Deploying Apllications

The Heroku platform uses git as the primary means for deploying applications. When you create an application on Heroku, it associates a new git remote, typically named heroku, with the local git repository for your application. As a result, deploying code is just the familiar git push, but to the heroku remote instead:

$ git push heroku master

Vlad

Vlad the Deployer is pragmatic application deployment automation, without mercy. Much like Capistrano, but with 1/10th the complexity. Vlad integrates seamlessly with Rake, and uses familiar and standard tools like ssh and rsync.

Features

  • Full deployment automation stack.
  • Turnkey deployment for passenger+apache+svn.
  • Supports single server deployment with just 3 variables defined.
  • Built on rake. Easy. Engine is small.
  • Very few dependencies. All simple.
  • Uses ssh with your ssh settings already in place.
  • Uses rsync for efficient transfers.
  • Run remote commands on one or more servers.
  • Mix and match local and remote tasks.
  • Compatible with all of your tab completion shell script rake-tastic goodness.
  • Ships with tests that actually pass in 0.028 seconds!

Comparison between Capistrano/Heroku/Vlad

Criteria Capistrano Heroku Vlad
"Take some more [[tea]]," the March Hare said to Alice, very earnestly.

"I've had '''nothing''' yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take ''less''?" said the Hatter. "It's very easy to take ''more'' than nothing."
<p>"Take some more <a title="Tea" href="/wiki/Tea">tea</a>," the March Hare said to Alice, very earnestly.</p>

<p>"I've had <strong>nothing</strong> yet," Alice replied in an offended tone, "so I can't take more."</p>

<p>"You mean you can't take <em>less</em>?" said the Hatter. "It's very easy to take <em>more</em> than nothing."</p>

"Take some more tea," the March Hare said to Alice, very earnestly.

"I've had nothing yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take less?" said the Hatter. "It's very easy to take more than nothing."

Conclusion

We compare and contrast between various deployment automated tools such as Capistrano, Heroku and Vlad. Among the three tools, Vlad is the one of the newest tools which is highly automated and faster in deploying applications than the other tools. It is the highly pragmatic tool which automates the entire process of code deployment and release management with Rails.

References

http://technet.microsoft.com

http://searchitchannel.techtarget.com/definition/release-management

http://www.capistranorb.com/documentation/getting-started/installation/

http://www.urbancode.com/html/solutions/deployment-automation.html

https://devcenter.heroku.com/articles/how-heroku-works#deploying-applications

https://github.com/heroku/heroku

http://docs.seattlerb.org/vlad/index.html

<references/>

See Also