VirtualBox+Vagrant+Chef(knife-solo) 環境構築(Windows 7+Cygwin) 苦戦記
前回記事
VirtualBox+Vagrant 環境構築(Windows 7+Cygwin) 苦戦記 - Status Code 303 - See Other
前回記事概要
Windowsでコンソールとして Cygwin を利用し、VirtualBox + Vagrant で仮想環境を作成できるようにした。
このとき、苦戦した内容と解決に至るまでをメモった。
この記事で記述すること
Chef を導入し、前回の仮想環境上にインフラ環境をセットアップする。
しかし、Cygwin で行うために少し面倒な設定が必要になる。
ソフトウェアについて
VirtualBox? Vagrant? Cygwin?
前回記事参照。
Chef?
Chef 社が提供。インフラ設定をコードで記述、設定したいサーバにコード内容を実行するためのツール。
サーバの構築内容をコードとして管理することができる。(Infrastructure as Code)
Chef には大きく2通りの形態があり(Chef-solo/Chef-Server + Chef-Client)、
今回は小規模向けである Chef Solo を用いる。この中でも拡張ユーティリティの knife-solo を用いる。
その他の Chef の種類や特徴については下記を。
あなたに合ったChefはどれ? 〜 おすすめ構成確認チャート #getchef - クリエーションライン株式会社
なんのため?
- 本番を想定したテスト環境を作成したり、その上で簡単なテストしたりするため。
- 継続的デリバリー(CD)を実現するため。
(参考:DevOps時代の開発者のための構成管理入門(終):継続的デリバリ/デプロイを実現する手法・ツールまとめ (1/2) - @IT)
環境構築
手順
Chef インストール 手順
gem を使ってインストールする方法もあるようだが、現在ではインストーラを使うのが主流らしい。
基本的に手順は以下を参考にさせてもらった。
Chef for Windows
Windows7にChef(11.6.0)とVagrant(1.7.2)を入れてプロビジョニングしてみた - カタカタブログ
つまずいたところ
インストール先の変更
インストーラがインストール先の選択が出る。ここで「E:\opscode\」を選択。
そうするとインストールは完了するが、Cygwin 上で実際に使ってみるとなぜか動かない。
調べるとどうやら、インストーラのバグらしい。(c:\opscode にあることを前提としたコードがある?)
Windows can't install into anything other than C:\opscode · Issue #68 · chef/chef-dk · GitHub
しかたないので、シンボリックリンクを作成し C:\opscode を E:\opscode に関連付けしてから再インストールした。
(再インストールしなくても動くかもだけど念のため)
※ 以下のコマンドに限り、管理者モードで起動したコマンドプロンプトを使用。
> mklink /d C:\opscode E:\opscode
Cygwin上のパスを制御する
Cygwin は Linux 環境をWindows上に作るだけあってそのフォルダ構成が異なる。
これが原因でエイリアスを設定しないと動かない。(コマンドが実行できない)
$ chef -v C:\opscode\chefdk\embedded\bin\ruby.exe: No such file or directory -- /cygdrive/c/opscode/chefdk/bin/chef (LoadError)
関連するエイリアスを全て設定に書き込み、その設定を現在のセッションに適用する。
(下記ではEドライブだが、Cドライブのファイル名で指定してもOK)
$ echo "alias chef='E:/opscode/chefdk/bin/chef'" >> ~/.bashrc $ echo "alias knife='E:/opscode/chefdk/bin/knife'" >> ~/.bashrc $ echo "alias gem='E:/opscode/chefdk/embedded/bin/gem'" >> ~/.bashrc $ source ~/.bashrc
これで次回から Cygwin を起動するたびに設定される。
knife solo の障害
Chef コマンドは動くようになった。次は knife solo コマンドを使うため下記を実行する。
gem install knife-solo gem install berkshelf chef gem install knife-solo
インストール完了後 knife solo コマンドを動かすがどうも動かない。knife configure も同様だ。
どうやら gem で使用するライブラリ(net-ssh)との依存関係が原因のようだ。
$ knife solo init . C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:2288:in `raise_if_conflicts': Unable to activate knife-solo-0.5.1, because net-ssh-3.1.1 conflicts with net-ssh (< 3.0, ~> 2.7) (Gem::ConflictError) from C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb:1408:in `activate' from C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:200:in `rescue in try_activate' from C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems.rb:193:in `try_activate' from C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in require' from C:/opscode/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:40:in `require' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.5.1/lib/chef/knife/cook.rb:1:in `<top (required)>' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:100:in `load' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:100:in `block in load_commands' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:100:in `each' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:100:in `load_commands' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:110:in `load_command' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife/core/subcommand_loader.rb:124:in `command_class_from' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:153:in `subcommand_class_from' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:214:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/knife.rb:148:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/knife:25:in `<top (required)>' from E:/opscode/chefdk/bin/knife:61:in `load' from E:/opscode/chefdk/bin/knife:61:in `<main>'
knife solo ユーティリティの既知の障害みたい。 Unable to activate knife-solo-0.5.1 · Issue #811 · chef/chef-dk · GitHub
直す方法を探したが、ダウングレード記事が多くあまり気が進まなかった。
ここでしばらく諦めモードに。
しかし、ver 0.6.0 でこの問題が直ったためアップデートして 0.5.1 -> 0.6.0 にアップデートすると動いた
$ knife configure WARNING: No knife configuration file found Where should I put the config file? [E:/cygwin/home/hoshikouki/.chef/knife.rb] Please enter the chef server URL: [https://hoshikouki-PC.flets-east.jp:443] Please enter an existing username or clientname for the API: [hoshikouki] Please enter the validation clientname: [chef-validator] Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] Please enter the path to a chef repository (or leave blank): ***** You must place your client key in: E:/cygwin/home/hoshikouki/.chef/hoshikouki.pem Before running commands with Knife ***** You must place your validation key in: E:/etc/chef-server/chef-validator.pem Before generating instance data with Knife ***** Configuration file written to E:/cygwin/home/hoshikouki/.chef/knife.rb
rsync コマンド失敗
Cookbook を作成し、debian-jessieホストを以下のコマンドで設定。
$ vagrant ssh-config --host debian-jessie >> ~/.ssh/config
リモート先で Chef 実行しようと knife solo bootstrap コマンド(prepare + cook コマンド)を実行。
$ knife solo bootstrap debian-jessie Bootstrapping Chef... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 19602 100 19602 0 0 17371 0 0:00:01 0:00:01 --:--:-- 17377 debian 8 x86_64 Getting information for chef stable 12.9.41 for debian... downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=12.9.41&p=debian&pv=8&m=x86_64 to file /tmp/install.sh.8361/metadata.txt trying wget... sha1 2f8503b7177437418337e7ad01064b77aefdafad sha256 3f54dd6121acaea52620a58cd06f4192cd7b0e6c82f2047f10876494c93ac89d url https://packages.chef.io/stable/debian/8/chef_12.9.41-1_amd64.deb version 12.9.41 downloaded metadata file looks valid... downloading https://packages.chef.io/stable/debian/8/chef_12.9.41-1_amd64.deb to file /tmp/install.sh.8361/chef_12.9.41-1_amd64.deb trying wget... Comparing checksum with sha256sum... Installing chef 12.9.41 installing with dpkg... (Reading database ... 63807 files and directories currently installed.) Preparing to unpack .../chef_12.9.41-1_amd64.deb ... Unpacking chef (12.9.41-1) over (12.9.41-1) ... Setting up chef (12.9.41-1) ... Thank you for installing Chef! Running Chef on debian-jessie... Uploading the kitchen... WARNING: Local cookbook_path 'E:/cygwin/home/hoshikouki/cookbooks' does not exist WARNING: Local role_path '.\roles' does not exist WARNING: Local data_bag_path '.\data_bags' does not exist WARNING: Local environment_path '.\environments' does not exist Generating solo config... rsync: link_stat "/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160605-18680-1tgoomz" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2] ERROR: RuntimeError: Failed to launch command ["rsync", "-rL", "--chmod=ugo=rwX", "--rsh=ssh vagrant@debian-jessie", "--delete-after", "-zt", "--exclude=revision-deploys", "--exclude=.git", "--exclude=.hg", "--exclude=.svn", "--exclude=.bzr", "/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160605-18680-1tgoomz", ":~/chef-solo/solo.rb"]
最後の行から察するに rsync か。またかい。
原因の切り分けをするために、knife solo prepare コマンド実行。(リモートに Chef solo 環境作成)
処理は成功。次に、knife solo cook コマンド(リモートに cookbook 適用)を実行すると同じエラーが出た。
どうやらここが原因らしい。
そして、調べてみると -VV (Vが2個) がデバッグモードになるらしく、これを使って調べてみた。
$ knife solo cook -VV debian-jessie INFO: Using configuration from E:/cygwin/home/hoshikouki/chef-repo/.chef/knife.rb Starting 'Run' Running Chef on debian-jessie... Checking Chef version... (長いので中略) sent 124 bytes received 11 bytes 270.00 bytes/sec total size is 0 speedup is 0.00 DEBUG: 'encrypted_data_bag_secret' not set DEBUG: ["rsync", "-rL", "-v", "--chmod=ugo=rwX", "--rsh=ssh vagrant@debian-jessie", "--delete-after", "-zt", "--exclude=revision-deploys", "--exclude=.git", "--exclude=.hg", "--exclude=.svn", "--exclude=.bzr", ".\\environments/", ":~/chef-solo/environments"] building file list ... done sent 124 bytes received 11 bytes 270.00 bytes/sec total size is 0 speedup is 0.00 Generating solo config... DEBUG: ["rsync", "-rL", "-v", "--chmod=ugo=rwX", "--rsh=ssh vagrant@debian-jessie", "--delete-after", "-zt", "--exclude=revision-deploys", "--exclude=.git", "--exclude=.hg", "--exclude=.svn", "--exclude=.bzr", "/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160607-9868-1vtkfpf", ":~/chef-solo/solo.rb"] building file list ... rsync: link_stat "/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160607-9868-1vtkfpf" failed: No such file or directory (2) done sent 81 bytes received 11 bytes 184.00 bytes/sec total size is 0 speedup is 0.00 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2] C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/knife-solo/tools.rb:4:in `system!': Failed to launch command ["rsync", "-rL", "-v", "--chmod=ugo=rwX", "--rsh=ssh vagrant@debian-jessie", "--delete-after", "-zt", "--exclude=revision-deploys", "--exclude=.git", "--exclude=.hg", "--exclude=.svn", "--exclude=.bzr", "/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160607-9868-1vtkfpf", ":~/chef-solo/solo.rb"] (RuntimeError) from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:279:in `rsync' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:233:in `upload' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:258:in `write' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:229:in `generate_solorb' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:97:in `block in run' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:212:in `time' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:79:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:421:in `block in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/local_mode.rb:44:in `with_server_connectivity' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:420:in `run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:219:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/knife.rb:148:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/knife:25:in `<top (required)>' from E:/opscode/chefdk/bin/knife:61:in `load' from E:/opscode/chefdk/bin/knife:61:in `<main>'
やはり rsync のようだ。最初は "Program Files の半角スペースが原因でコマンドが認識できていないのかと思ったが、
配列からコマンドを作成するこの記述方法なら問題なさそうだ。・・・原因分からねえ。
そして、ある時閃いた。
- cygwin 直下のこのパスってtmpフォルダなんてあったっけ? →残念あった
- Program Files 以下って書き込み権限あったっけ? →なかった
ユーザの書き込み権限を「書き込み」許可すると動いた。(tmp フォルダ上で右クリック->プロパティのセキュリティタブ)
どうやら「/cygdrive/C/Program Files/cygwin64/tmp/solo.rb20160607-9868-1vtkfpf」に書き込みができなくてダメだったようだ。
ユーザの書き込み権限をエクスプローラから「書き込み」許可すると先ほどの場所は抜けた。
謎のエラー
rsync は直ったようだが、まだエラーが残っていた。次の問題部分。
DEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: DEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: from /usr/bin/chef-solo:51:in `<main>' from /usr/bin/chef-solo:51:in `<main>'DEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:315:in `cook': chef-solo failed. See output above. (RuntimeError) from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:99:in `block in run' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:212:in `time' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:79:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:421:in `block in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/local_mode.rb:44:in `with_server_connectivity' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:420:in `run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:219:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/knife.rb:148:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/knife:25:in `<top (required)>' from E:/opscode/chefdk/bin/knife:61:in `load' from E:/opscode/chefdk/bin/knife:61:in `<main>'
- VV オプション付けるとメッセージが違う。不思議。
Generating solo config... Running Chef: sudo chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/config_fetcher.rb:47:in `read': Is a directory @ io_fread - /home/vagrant/chef-solo/solo.rb (Errno::EISDIR) from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/config_fetcher.rb:47:in `read_local_config' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/config_fetcher.rb:36:in `read_config' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:107:in `load_config_file' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:85:in `configure_chef' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:47:in `reconfigure' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/solo.rb:210:in `reconfigure' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application.rb:56:in `run' from /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/chef-solo:25:in `<top (required)>' from /usr/bin/chef-solo:51:in `load' from /usr/bin/chef-solo:51:in `<main>' ERROR: RuntimeError: chef-solo failed. See output above.
/home/vagrant/chef-solo/solo.rb はディレクトリだよ?
パスを見るに 仮想環境上のようだ。乗り込んで確かめてみると、
たしかに「/home/vagrant/chef-solo/solo.rb」はディレクトリだった。
なんでこんなことになっていたのか・・・。謎のディレクトリを削除してみると、進んだ。
$ sudo rm -rf /home/vagrant/chef-solo/solo.rb
リソースが見つからない。
Cookbook に作成した hello リソースが見つからないらしい。
/usr/bin/chef-solo:51:in `<main>' [2016-06-07T15:43:59+00:00] ERROR: Cookbook hello not found. If you're loading hello from another cookbook, make sure you configure the dependency in your metadata DEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: [2016-06-07T15:43:59+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) [2016-06-07T15:43:59+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:315:in `cook': chef-solo failed. See output above. (RuntimeError) from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:99:in `block in run' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:212:in `time' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:79:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:421:in `block in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/local_mode.rb:44:in `with_server_connectivity' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:420:in `run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:219:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/knife.rb:148:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/knife:25:in `<top (required)>' from E:/opscode/chefdk/bin/knife:61:in `load' from E:/opscode/chefdk/bin/knife:61:in `<main>'
ためしに dstat リソースを新しく作成して同様の手順を行う。しかし、結果は同じ。
DEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: [2016-06-07T15:54:55+00:00] ERROR: Cookbook dstat not found. If you're loading dstat from another cookbook, make sure you configure the dependency in your metadata [2016-06-07T15:54:55+00:00] ERROR: Cookbook dstat not found. If you're loading dstat from another cookbook, make sure you configure the dependency in your metadataDEBUG: sudo -p 'knife sudo password: ' chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json -l debug stdout: [2016-06-07T15:54:55+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:315:in `cook': chef-solo failed. See output above. (RuntimeError) from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:99:in `block in run' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:212:in `time' from C:/Users/hoshikouki/AppData/Local/chefdk/gem/ruby/2.1.0/gems/knife-solo-0.6.0/lib/chef/knife/solo_cook.rb:79:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:421:in `block in run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/local_mode.rb:44:in `with_server_connectivity' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:420:in `run_with_pretty_exceptions' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/knife.rb:219:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/application/knife.rb:148:in `run' from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/bin/knife:25:in `<top (required)>' from E:/opscode/chefdk/bin/knife:61:in `load' from E:/opscode/chefdk/bin/knife:61:in `<main>'
作成したリソースを Chef が認識していないようだ。
- Berkshelf が悪さしている? (違った)
chef (11.6.0) + knife-solo (0.3.0.pre5)は相性が悪いっぽい? - じゅにゃくんのはてブロ。 - cookbook の設定を書く場所が悪かった (ビンゴ)
knife-soloによるChefの実行 - Qiita
cookbook_path ["cookbooks", "site-cookbooks"] node_path "nodes" role_path "roles" environment_path "environments" data_bag_path "data_bags" #encrypted_data_bag_secret "data_bag_key" knife[:berkshelf_path] = "cookbooks"
※ これを ~/.chef/knife.rb (ホームディレクトリ直下)に書いてたから動かなかった
そして、 knife solo cook が成功。(gitリソースまで作成してから行ってます)
$ knife solo cook debian-jessie Running Chef on debian-jessie... Checking Chef version... Installing Berkshelf cookbooks to 'E:/cygwin/home/hoshikouki/.berkshelf/knife-solo/741e61ac3fba69a26087f2d0c26ffc30e967a5f2'... Resolving cookbook dependencies... Uploading the kitchen... WARNING: Local cookbook_path 'E:/cygwin/home/hoshikouki/.berkshelf/knife-solo/741e61ac3fba69a26087f2d0c26ffc30e967a5f2' does not exist Generating solo config... Running Chef: sudo chef-solo -c ~/chef-solo/solo.rb -j ~/chef-solo/dna.json Starting Chef Client, version 12.9.41 [2016-06-07T17:10:27+00:00] WARN: The cookbook(s): dstat exist in multiple places in your cookbook_path. A composite version has been compiled. This has been deprecated since 0.10.4, in Chef 13 this behavior will be REMOVED. at /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.9.41/lib/chef/cookbook_loader.rb:89:in `load_cookbooks' Installing Cookbook Gems: Compiling Cookbooks... Converging 3 resources Recipe: dstat::default * apt_package[dstat] action remove (up to date) * apt_package[git] action install (up to date) Recipe: hello::default * log[hello world!!!!!] action write Running handlers: Running handlers complete