msfukuiの日記

おおまさのみみはそらのみみ。

cygwin の knife-solo で knife solo cook に失敗する件の回避方法

いつものことながら自分用のメモ。
prepare には成功するのですが、cook に失敗していました。
VirtualBox + Vagrant で構成した以下の環境のお話になります。

[ ~]$ cd vagrant/scientificlinux6.4/
[ scientificlinux6.4]$ ls
Vagrantfile*
[ scientificlinux6.4]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 22 => 10024 (adapter 1)
[default] -- 3000 => 3001 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[ scientificlinux6.4]$ cd ../chef-repo
[ chef-repo]$ knife solo prepare spotty
Bootstrapping Chef...
Enter the password for bpsn308@spotty:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13347 100 13347 0 0 2244 0 0:00:05 0:00:05 --:--:-- 41840

Downloading Chef 11.8.2 for el...
downloading https://www.opscode.com/chef/metadata?v=11.8.2&prerelease=false&p=el&pv=6&m=x86_64
to file /tmp/install.sh.2052/metadata.txt
trying wget...
url https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-11.8.2-1.el6.x86_64.rpm
md5 10f3d0da82efa973fe91cc24a6a74549
sha256 044558f38d25bbf75dbd5790ccce892a38e5e9f2a091ed55367ab914fbd1cfed
downloaded metadata file looks valid...
downloading https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-11.8.2-1.el6.x86_64.rpm
to file /tmp/install.sh.2052/chef-11.8.2-1.el6.x86_64.rpm
trying wget...
Checksum compare with sha256sum succeeded.
Installing Chef 11.8.2
installing with rpm...
警告: /tmp/install.sh.2052/chef-11.8.2-1.el6.x86_64.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
準備中... ########################################### [100%]
1:chef ########################################### [100%]
Thank you for installing Chef!
[ chef-repo]$ knife solo cook -V spotty
Starting 'Run'
Running Chef on spotty...
Checking Chef version...
Enter the password for bpsn308@spotty:
Uploading the kitchen...
sending incremental file list
chef-solo-search/.travis.yml
chef-solo-search/CHANGELOG
chef-solo-search/LICENSE
chef-solo-search/NOTICE
chef-solo-search/README.md
chef-solo-search/metadata.rb
chef-solo-search/libraries/search.rb
chef-solo-search/libraries/search/overrides.rb
chef-solo-search/libraries/search/parser.rb
chef-solo-search/libraries/vendor/chef/solr_query/lucene.treetop
chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb
chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb
chef-solo-search/recipes/default.rb
chef-solo-search/tests/Gemfile
chef-solo-search/tests/test_data_bags.rb
chef-solo-search/tests/test_search.rb
chef-solo-search/tests/data/data_bags/node/alpha.json
chef-solo-search/tests/data/data_bags/node/beta.json
chef-solo-search/tests/data/data_bags/node/without_json_class.json
chef-solo-search/tests/data/data_bags/users/jerry.json
chef-solo-search/tests/data/data_bags/users/lea.json
chef-solo-search/tests/data/data_bags/users/mike.json
chef-solo-search/tests/data/data_bags/users/tom.json

sent 2021 bytes received 953 bytes 5948.00 bytes/sec
total size is 47483 speedup is 15.97
ERROR: Net::SSH::Disconnect: connection closed by remote host
[ chef-repo]$

エラーの内容からこちらの issue を拝見しまして、
Failure 'connection closed by remote host' happens when `knife solo cook` is executed under cygwin · Issue #332 · matschaffer/knife-solo · GitHub

こちらに従ってパッチをあてまして、
don't reuse ssh connection, it don't work well under cygwin #332 · keeruline/knife-solo@d57894b · GitHub

再度実行したらちょっと時間は掛かりますが、うまく流れてくれました!

[ chef-repo]$ knife solo cook spotty
Running Chef on spotty...
Checking Chef version...
Enter the password for bpsn308@spotty:
Uploading the kitchen...
Generating solo config...
Running Chef...

Starting Chef Client, version 11.8.2
Compiling Cookbooks...
Converging 6 resources
Recipe: timezone::default
* template[/etc/sysconfig/clock] action create (up to date)
* execute[timezone_update] action nothing (skipped due to action :nothing)
Recipe: yumsetup::default
* yum_package[yum-fastestmirror] action install
- install version 1.1.30-14.el6 of package yum-plugin-fastestmirror

* execute[yum-update] action run

- execute yum -y update

Recipe: lang-ja::default
* execute[lang-ja] action run
- execute yum -y groupinstall "Japanese Support"

* template[/etc/sysconfig/i18n] action create
- update content in file /etc/sysconfig/i18n from 652f73 to 86a49d
--- /etc/sysconfig/i18n 2013-11-25 01:52:37.208000019 +0900
+++ /tmp/chef-rendered-template20140210-3146-16ndquu 2014-02-10 10:22:14.030179718 +0900
@@ -1,2 +1,3 @@
LANG="ja_JP.UTF-8"
+SYSFONT="latarcyrheb-sun16"
- change mode from '0644' to '01204'

Chef Client finished, 4 resources updated
[ chef-repo]$

一時的な回避策でしかない、とのことですが、闇が深そうなので一旦これ以上の追及は行わないことにします..。
これで Windows 上での開発環境の構築がもうちょっとはかどるとよいなあ。