windows+CygwinでChef - 6.berkshelfインストール編
これまでで、取り合えず、ミドルウェアの設定くらいは簡単に行えるようになってきました。
今一緒に働いている人に、berkshelfってツールの事を聞いたので、
良いタイミングだって事で、会社にて導入・・・そして・・・ハマるw
Cygwinでメッチャハマりましたw
そんなこんなで、ハマった内容や、Berkshelfについての解説なども含めて書いていきたいと思います。
Windos+Chef入門目次を作成しました!
参考にしたサイト
BerkshelfとChefのインストールに苦労した話 - DQNEO起業日記
WindowsでのBerkshelfのインストール成功 | 5丁目通信(仮称)
64bit 版で gem install ffi すると native extension のコンパイルに失敗する件の回避方法 - msfukuiの日記
Berkshelfとは?
そもそもBerkshelfって何だ?って事で調査を開始!
Berkshelfとは、cookbookを管理してくれるツールのような感じみたいですね。
rubyのgemを管理しているBundlerみたいな感じですね!
Berkfileに色々書いて実行すると、cookbookに依存するものを、適切にセットアップしてくれるようです!
Berkshelfのインストール
Berkshelfはgemで配布されており、gem installからインストールできます!
早速インストールしてみたいと思います。
$ gem install berkshelf DL is deprecated, please use Fiddle Fetching: addressable-2.3.6.gem (100%) Successfully installed addressable-2.3.6 Fetching: multipart-post-2.0.0.gem (100%) ・・・中略・・・ ERROR: Error installing berkshelf: ERROR: Failed to build gem native extension. ・・・中略・・・ Gem files will remain installed in /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/dep-selector-libgecode-1.0.1 for inspection. Results logged to /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-cygwin/2.1.0/dep-selector-libgecode-1.0.1/gem_make.out
ハイ!エラー!w調べると、何か色々ライブラリが足らないって言われました・・・。
apt-cygで色々入れておきたいと思います。
今回は、色んなサイトで必要!って書いてあったライブラリをとことん入れてやりましたw
$ apt-cyg install gcc-core gcc-g++ make zlib-devel curl openssl-devel libiconv-devel libncurses-devel libxml2-devel libxslt-devel libffi-devel cygwin32-libffi pkg-config libffi6
再度実行します!
$ gem install berkshelf DL is deprecated, please use Fiddle Building native extensions. This could take a while... ERROR: Error installing berkshelf: ERROR: Failed to build gem native extension. /cygdrive/c/pik/.rbenv/versions/2.1.2/bin/ruby.exe extconf.rb -> sh /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/dep-selector-libgecode-1.0.1/ext/libgecode3/vendor/gecode-3.7.3/configure --prefix=/cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/dep-selector-libgecode-1.0.1/lib/dep-selector-libgecode/vendored-gecode --disable-doc-dot --disable-doc-search --disable-doc-tagfile --disable-doc-chm --disable-doc-docset --disable-qt --disable-examples --disable-flatzinc checking for the host operating system... Windows checking whether the C++ compiler works... no configure: error: in `/cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/dep-selector-libgecode-1.0.1/ext/libgecode3/vendor/gecode-3.7.3': configure: error: C++ compiler cannot create executables See `config.log' for more details extconf.rb:94:in `block in run': Failed to build gecode library. (GecodeBuild::BuildError) from extconf.rb:93:in `chdir' from extconf.rb:93:in `run' from extconf.rb:100:in `<main>' extconf failed, exit code 1 Gem files will remain installed in /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/dep-selector-libgecode-1.0.1 for inspection. Results logged to /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-cygwin/2.1.0/dep-selector-libgecode-1.0.1/gem_make.out
またエラー!今度はなんだー!w
「Failed to build gecode library」って所のビルドで失敗しているようです。。
色々調べてみると、Berkshelfのバージョンが3にあがってしまって、
gemのバージョンいマッチしていないとの情報が。。。
Berkshelfのバージョンを2系統にあわせて入れてみたいと思います。
$ gem install berkshelf -v '2.0.16' ・・・・中略・・・・ IMPORTANT! Nokogiri builds and uses a packaged version of libxml2. If this is a concern for you and you want to use the system library instead, abort this installation process and reinstall nokogiri as follows: gem install nokogiri -- --use-system-libraries If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install However, note that nokogiri does not necessarily support all versions of libxml2. ・・・・中略・・・・ ERROR: Error installing berkshelf: ERROR: Failed to build gem native extension. ・・・・中略・・・・ Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-unknown-cygwin/ports/libxml2/2.8 .0... OK Running patch with /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gem s/nokogiri-1.6.3.rc1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-pr oblems.patch... Running 'patch' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-unknown-cygwin/po rts/libxml2/2.8.0/patch.log' to see what happened. * extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. ・・・中略・・・・ Gem files will remain installed in /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/rub y/gems/2.1.0/gems/nokogiri-1.6.3.rc1 for inspection. Results logged to /cygdrive/c/pik/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/exte nsions/x86_64-cygwin/2.1.0/nokogiri-1.6.3.rc1/gem_make.out
あらー・・・・こりゃまたエラーが大量に・・・w
読み解くと、「gem install nokogiri -- --use-system-libraries」を実行しろって書いてあるので、
ひとまず、実行してみます。
ってか、何でnokogiriが必要なんだろうか・・・?w
$ gem install nokogiri -- --use-system-libraries DL is deprecated, please use Fiddle Building native extensions with: '--use-system-libraries' This could take a while... Building nokogiri using system libraries. Successfully installed nokogiri-1.6.2.1 Parsing documentation for nokogiri-1.6.2.1 Installing ri documentation for nokogiri-1.6.2.1 Done installing documentation for nokogiri after 3 seconds 1 gem installed
入ったので、再度実行・・・・!
$ gem install berkshelf -v '2.0.16' DL is deprecated, please use Fiddle ・・・中略・・・ Parsing documentation for ridley-1.7.1 Installing ri documentation for ridley-1.7.1 Parsing documentation for rubyntlm-0.1.1 Installing ri documentation for rubyntlm-0.1.1 Parsing documentation for savon-0.9.5 Installing ri documentation for savon-0.9.5 Parsing documentation for solve-0.8.2 Installing ri documentation for solve-0.8.2 Parsing documentation for thor-0.18.1 Installing ri documentation for thor-0.18.1 Parsing documentation for uuidtools-2.1.4 Installing ri documentation for uuidtools-2.1.4 Parsing documentation for varia_model-0.3.2 Installing ri documentation for varia_model-0.3.2 Parsing documentation for wasabi-1.0.0 Installing ri documentation for wasabi-1.0.0 Parsing documentation for winrm-1.1.3 Installing ri documentation for winrm-1.1.3 Done installing documentation for akami, berkshelf, buff-config, buff-extensions, ffi, gssapi, gyoku, httpclient, rbzip2, ridley, rubyntlm, savon, solve, thor, uuidtools, varia_model, wasabi, winrm after 21 seconds 18 gems installed
おおー!w入った!入りましたよー!
ちなみに、会社では、cygwin64でハマったんですが。。。。なんだったんだろうか・・・
会社のPCの場合は、「export PKG_CONFIG_PATH="/lib/pkgconfig"」を実行したら、
うまくいきました!
こちらのページが参考になりました
64bit 版で gem install ffi すると native extension のコンパイルに失敗する件の回避方法 - msfukuiの日記
実行環境の用意
今回も前回と同様、実行環境を用意しておきたいと思います。
前回の仮想マシンをdestroyして、新たに作成します。
$ mkdir chef_13 $ cd ./chef_13 $ vagrant init centos6.5 $ vagrant up #鍵認証 $ vagrant ssh-config --host chef_13 >> ~/.ssh/config #接続テスト $ ssh chef_13 Welcome to your Vagrant-built virtual machine. [vagrant@localhost ~]$ exit logout Connection to 127.0.0.1 closed. #リポジトリの作成と仮想マシンにchefを用意 $ knife solo init berktest Creating kitchen... Creating knife.rb in kitchen... Creating cupboards... DL is deprecated, please use Fiddle Setting up Berkshelf... $ cd berktest $ knife solo prepare chef_13
今作成した、レポジトリを確認すると、今までには無い「Berksfile」っていうのが作成されていると思います。
こちらを使っていくことになりますので、要チェックです!
今回は、windowsにberkshelfをインストールするところを重点的に書きました!
実際インストールするのに、すごい時間かかってしまったので、
ハマりやすそうなので、要注意ですね。。。
次回は、Berkshelfを使って、nginxあたりを入れてみようかと思います!
使用環境
- ホストOS: Windows7 x64
- Cygwin : Cygwin64
- VirtualBox: 4.3.10
- Vagrant: 1.5.2
- Chef : 11.12.4
- knife-solo:0.4.1