Capistrano is an open source tool for running scripts on multiple servers; its main use is deploying web applications. It automates the process of making a new version of an application available on one or more web servers, including supporting tasks such as changing databases. Capistrano is written in the Ruby language and is distributed using the RubyGems distribution channel. It is an outgrowth of the Ruby on Rails web application framework, but has also been used to deploy web applications written using other frameworks, including ones written in PHP. The usage on the bash command line is easy to learn. When used with the Ruby on Rails Framework many default Capistrano recipes can be used, e.g. to deploy current changes to the web application or roll back to the previous deployment state.
Installation
#apt-get install ruby1.8 ruby1.8-dev rubygems1.8 libruby-extras libruby1.8-extras (Ubuntu / Debian)#yum install ruby1.8 ruby1.8-dev rubygems1.8 libruby-extras libruby1.8-extras (Centos / Redhat)Check the Ruby Details
#ruby -vruby 1.8.7 OK,Lets move to install Capistrano Boy
#gem install -y capistrano echoeCapistrano makes a few assumptions about your servers. In order to use Capistrano, you will need to comply with these assumptions:
- You are using SSH to access your remote machines. Telnet and FTP are not supported.
- Your remote servers have a POSIX-compatible shell installed. The shell must be called “sh” and must reside in the default system path.
- If you are using passwords to access your servers, they must all have the same password. Because this is not generally a good idea, the preferred way of accessing your
- servers is with a public key. Make sure you’ve got a good passphrase on your key.
We are going to trigger some examples here. So my remote servers are 192.168.1.12 and 192.168.1.13 (You can Add any number here).
In the following example we are going to check the uptime of above servers.
Copy paste the following code into a text editor (Vim,Emacs).
task :health, :hosts => "192.168.1.12" , "192.168.1.13" dorun "uptime"endSave the file with name "capfile" without any extension.
Wakeup the code
#cap healthI found that some times while you apply this command shell returned an error "Command not found",then do the following
#vi ~/.bashrcCopy paste the following at the end of the File
export PATH=$PATH:/var/lib/gems/1.8/binThen rebuild the bashrc
# source ~/.bashrcThen Re-run the command,If you are against a password access server,it will ask for the password,enter it,other wise the result will be like following
[192.168.1.12] executing command
[192.168.1.13] executing command
** [out :: 192.168.1.12] 11:30:55 up 27 days, 22:40, 0 users, load average: 0.01, 0.01, 0.00
** [out :: 192.168.1.12] 11:30:55 up 37 days, 08:40, 0 users, load average: 0.05, 0.01, 0.08
command finished
We Can Do any command by the above said method,I hope you will be happy if you have a critical update on all of your 100 servers ...
Is int it ?