LoginSignup
16
15

More than 5 years have passed since last update.

Rubyを全く知らない素人エンジニアが素のCentOS6.3に0からknife-solo 0.3.0をインストールする手順

Last updated at Posted at 2013-05-22

入門chef-soloを読みながら、knife-soloのインストールでかなりハマったのでメモです。

書籍では0.3.0の導入がオススメされており、その方法として、

Zsh
$ git clone git://github.com/matschaffer/knife-solo.git
$ cd knife -solo
$ rake install

とgit cloneする方法が紹介されていますが、
"rubyこわい" "gemこわい" "rakeこわい"状態の筆者が行ったところハマるハマる。

とりあえずrubyの事を知らずとも、
0.3.0を手っ取り早く入れたいなら以下のコマンドで十分です。

Zsh
$ yum install rubygems ruby-devel
$ gem install knife-solo  --pre

※素のCentOS6.3にいきなりknife-soloをインストールすることなんて滅多にないと思いますが、
普段rubyでの開発を行なっておらず、必要なモジュールなども揃っていない状態で
最小限こんだけやればいけるよ、という感じでお考え下さい。

以下のブログを参考にさせて頂きました。ありがとうございます。
http://rochefort.hatenablog.com/entry/2013/04/26/022303


ちなみに、
git cloneする方法もメリットはありまして、
最新版を確実にインストールすることができます。
gem install knife-solo --preだとknife-solo-0.3.0.pre3が入りますが、
gitから落とせばknife-solo-0.3.0.pre4を入れることができます。
(2013/05/22現在)
(pre3からpre4にするメリットは知りません、すみません。勉強します)

せっかくなので、
Rubyを全く知らない素人エンジニアが素のCentOS6.3に0からknife-solo 0.3.0をgitでインストールする手順 も示しておきます。

以下、必要に応じてsudoするなりしてください。

yumでgcc(rakeで必要),git,rubygems(gemコマンド),ruby-devel(rakeで必要)をインストール

Zsh
$ yum install gcc git rubygems ruby-devel

〜〜中略〜〜
Installed:
  gcc.x86_64 0:4.4.7-3.el6               git.x86_64 0:1.7.1-3.el6_4.1               ruby-devel.x86_64 0:1.8.7.352-10.el6_4               rubygems.noarch 0:1.3.7-1.el6

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6            compat-readline5.x86_64 0:5.2-17.1.el6            cpp.x86_64 0:4.4.7-3.el6                glibc-devel.x86_64 0:2.12-1.107.el6
  glibc-headers.x86_64 0:2.12-1.107.el6        kernel-headers.x86_64 0:2.6.32-358.6.2.el6        mpfr.x86_64 0:2.4.1-6.el6               perl-Error.noarch 1:0.17015-4.el6
  perl-Git.noarch 0:1.7.1-3.el6_4.1            ppl.x86_64 0:0.10.2-11.el6                        ruby.x86_64 0:1.8.7.352-10.el6_4        ruby-irb.x86_64 0:1.8.7.352-10.el6_4
  ruby-libs.x86_64 0:1.8.7.352-10.el6_4        ruby-rdoc.x86_64 0:1.8.7.352-10.el6_4

Complete!

gemでrake,bundlerをインストール

Zsh
$ gem install rake bundler

Successfully installed rake-10.0.4
Successfully installed bundler-1.3.5
2 gems installed
Installing ri documentation for rake-10.0.4...
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for rake-10.0.4...
Installing RDoc documentation for bundler-1.3.5...

githubから最新版をclone

Zsh
$ git clone git://github.com/matschaffer/knife-solo.git

Initialized empty Git repository in /root/knife-solo/.git/
remote: Counting objects: 4320, done.
remote: Compressing objects: 100% (2283/2283), done.
remote: Total 4320 (delta 1953), reused 4066 (delta 1728)
Receiving objects: 100% (4320/4320), 859.72 KiB | 345 KiB/s, done.
Resolving deltas: 100% (1953/1953), done.

最新版だとresources以下がごっそりsubmodule化しているので
以下のようにしてupdate

Zsh
$ cd knife-solo
$ git submodule init

Submodule 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search' (https://github.com/edelight/chef-solo-search.git) registered for path 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search'

$ git submodule update

Initialized empty Git repository in /root/knife-solo/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/.git/
remote: Counting objects: 352, done.
remote: Compressing objects: 100% (208/208), done.
remote: Total 352 (delta 150), reused 322 (delta 133)
Receiving objects: 100% (352/352), 60.77 KiB, done.
Resolving deltas: 100% (150/150), done.
Submodule path 'lib/knife-solo/resources/patch_cookbooks/chef-solo-search': checked out '5ba022d02c51cafc7b5323c1209fbb7936e4f60b'

rake install

Zsh
$ rake install

knife-solo 0.3.0.pre4 built to pkg/knife-solo-0.3.0.pre4.gem.
rake aborted!
Couldn't install gem, run `gem install ~/knife-solo/pkg/knife-solo-0.3.0.pre4.gem' for more detailed output

Tasks: TOP => install
(See full trace by running task with --trace)

何故かコケるが、ここで作成されたgemファイルを指定してinstallしたら成功する。

Zsh
$ gem install ./pkg/knife-solo-0.3.0.pre4.gem

〜〜中略〜〜

Thanks for installing knife-solo!

〜〜中略〜〜
Successfully installed mixlib-config-1.1.2
Successfully installed mixlib-cli-1.3.0
Successfully installed mixlib-log-1.6.0
Successfully installed mixlib-authentication-1.3.0

動作確認

Zsh
$ knife solo

FATAL: Cannot find sub command for: 'solo'
Available solo subcommands: (for details, knife SUB-COMMAND --help)

** SOLO COMMANDS **
knife solo init DIRECTORY
knife solo clean [USER@]HOSTNAME
knife solo cook [USER@]HOSTNAME [JSON] (options)
knife solo bootstrap [USER@]HOSTNAME [JSON] (options)
knife solo prepare [USER@]HOSTNAME [JSON] (options)

使い方が違う!と怒られますが、上記の表示が出れば成功です。

以下のブログを参考にさせて頂きました。ありがとうございます!
http://blog.fkoji.com/2013/04301203.html
http://d.hatena.ne.jp/yamanetoshi/20130325/1364196209

16
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
15