Capistrano導入
環境
- OS
- Ubuntu 10.04
- Capistrano
- 2.6.0
手順
capistrano インストール
$ sudo gem install capistrano [sudo] password for atsm: Fetching: highline-1.6.2.gem (100%) Fetching: net-ssh-2.1.4.gem (100%) Fetching: net-sftp-2.0.5.gem (100%) Fetching: net-scp-1.0.4.gem (100%) Fetching: net-ssh-gateway-1.1.0.gem (100%) Fetching: capistrano-2.6.0.gem (100%) Successfully installed highline-1.6.2 Successfully installed net-ssh-2.1.4 Successfully installed net-sftp-2.0.5 Successfully installed net-scp-1.0.4 Successfully installed net-ssh-gateway-1.1.0 Successfully installed capistrano-2.6.0 6 gems installed $ gem list capistrano *** LOCAL GEMS *** capistrano (2.6.0)
Railsアプリ作成
$ rails new blog_test
アプリのルートに移動して
$ cd blog_test
capify
$ capify . [add] writing './Capfile' [add] writing './config/deploy.rb' [done] capified!
deploy.rb修正
$ vim config/deploy.rb
set :application, "blog_test" set :user, "user" set :password, "password" role :test, "192.168.198.129" role :app, "192.168.198.129" task :hw, :roles => [:test] do run "echo Hellow World! $HOSTNAME" end task :gb, :roles => [:test, :app] do run "echo GoodBye! $HOSTNAME" end
cap実行
$ cap -f config/deploy.rb hw * executing `hw' * executing "echo Hellow World! $HOSTNAME" servers: ["192.168.198.129"] [192.168.198.129] executing command ** [out :: 192.168.198.129] Hellow World! command finished in 2018ms
$HOSTNAME が展開されないなあ・・・
追記
$ sudo gem install capistrano_colors Fetching: capistrano_colors-0.5.4.gem (100%) Successfully installed capistrano_colors-0.5.4 1 gem installed
$ sudo gem install capistrano-ext Fetching: capistrano-ext-1.2.1.gem (100%) Successfully installed capistrano-ext-1.2.1 1 gem installed