veeweeのbuildコマンドでエラーがでまくって疲れてる
こちらのサイトを参考に、
bundle exec veewee vbox define centos63-reallyminimal ‘CentOS-6.3-x86_64-reallyminimal’
ついで、
Bundle exec veewee vbox build centos63-reallyminimal
とすると、VirtualBoxが勝手に立ち上がり、sshで勝手にアクセスしていろいろ実行してくれる。これはすごい。しかしながら、またしても途中でエラー。
Executing command: echo 'vagrant'|sudo -S sh './postinstall.sh' : command not foundine 2: : command not foundine 4: : invalid option: line 7: set: - set: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...] ERROR: exit code 2 Error executing command echo 'vagrant'|sudo -S sh './postinstall.sh' : Exitcode was not what we expected Exitcode was not what we expected
うーん、わかんないよ、わかんないよ。と悩んでいたが、これは、postinstall.shの改行コードがCRLFとなっていたのが原因だった。このスクリプト自体をなおしてもいいんだけど、それってコマンド一発で全自動化するっていう思想と逆行してない?とおもって、もとのRubyスクリプトを修正することにした。
ファイルはこれ
.\live\veewee\provider\core\helper\ssh.rb
大体66行目からssh_transfer_fileという関数が定義されているのでこいつを治す。
Net::SSH.start( host,options[:user],options ) do |ssh| ui.info "Transferring #{filename} to #{destination} " ssh.scp.upload!( filename, destination ) do |ch, name, sent, total| # print "\r#{destination}: #{(sent.to_f * 100 / total.to_f).to_i}%" env.ui.info ".",{:new_line => false , :prefix => false} end
ShellスクリプトたちをtrコマンドつかってCRを取り除くように変更する。一方で、同様に転送されるisoファイルはいじらないようにする。
Net::SSH.start( host,options[:user],options ) do |ssh| ui.info "Transferring #{filename} to #{destination} " if destination[-3,3] == 'iso' dest2 = destination else dest2 = "#{destination}.t" end ssh.scp.upload!( filename, "#{dest2}" ) do |ch, name, sent, total| # print "\r#{destination}: #{(sent.to_f * 100 / total.to_f).to_i}%" env.ui.info ".",{:new_line => false , :prefix => false} end if dest2 != destination ui.info "Remove CR from #{dest2} then create #{destination} " ssh.exec! "tr -d '\r' < #{dest2} > #{destination} && rm -f #{dest2}" end
Rubyってわかりやすくていいな。
さらに、すすめていくと今度はこんなエラー。X Windowがないから?
Verifying archive integrity... All good. Uncompressing VirtualBox 4.2.16 Guest Additions for Linux............ VirtualBox Guest Additions installer Removing installed version 4.2.16 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... Removing existing VirtualBox DKMS kernel modules [ OK ] Removing existing VirtualBox non-DKMS kernel modules [ OK ] Building the VirtualBox Guest Additions kernel modules [ OK ] Doing non-kernel setup of the Guest Additions [ OK ] You should restart your guest to make sure the new modules are actually used Installing the Window System drivers [FAILED] (Could not find the X.Org or XFree86 Window System.)
方方調べて、postinstall.shのなかで、VBoxGuestAdditionを行う前に、yum -y groupinstall “X Window System” を行うようにしてみた。はあ、面倒くせー。
さらにこれでもう十分だろうと思うと、またまたエラーがでた
+ mount -o loop /home/vagrant/VBoxGuestAdditions_4.2.16.iso /mnt + sh /mnt/VBoxLinuxAdditions.run --nox11 Verifying archive integrity... All good. Uncompressing VirtualBox 4.2.16 Guest Additions for Linux............ VirtualBox Guest Additions installer Copying additional installer modules ... Installing additional modules ... Removing existing VirtualBox DKMS kernel modules[ OK ] Removing existing VirtualBox non-DKMS kernel modules[ OK ] Building the VirtualBox Guest Additions kernel modules[ OK ] Doing non-kernel setup of the Guest Additions[ OK ] Starting the VirtualBox Guest Additions [ OK ] Installing the Window System drivers Installing X.Org Server 1.13 modules[ OK ] Setting up the Window System to use the Guest Additions[ OK ] You may need to restart the hal service and the Window System (or just restart the guest system) to enable the Guest Additions. Installing graphics libraries and desktop services components[ OK ] ERROR: exit code 1 Error executing command echo 'vagrant'|sudo -S sh './postinstall.sh' : Exitcode was not what we expected Exitcode was not what we expected
現時点では上記エラーの理由はまったく不明。なにが悪いのか一個一個潰すのは大変だ……もう疲れたよ。
ついでに別の困ったところ。Windowsからsshでつなごうとすると、boxを再作成した合には、こんなエラーがでる。ちなみにWindowsではsshは標準コマンドではないので、mingw/msysをインストールしてつかっている。でもどこからインストールしたか覚えてない。
[D:\J-Drive\developments\projects\veewee\definitions\centos-6.3-reallyminimal] $ ssh -p 7222 root@localhost @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is d3:95:43:f1:71:79:c6:2b:fc:91:94:d8:38:ea:c5:5c. Please contact your system administrator. Add correct host key in /usr/home/.ssh/known_hosts to get rid of this message. Offending key in /usr/home/.ssh/known_hosts:5 RSA host key for [localhost]:7222 has changed and you have requested strict checking. Host key verification failed.
これはknown_hostsに古いboxでのキーが登録されていて、それが新しいboxと合致しないからなのです。以下URLを参考にしました。
http://futuremix.org/2007/08/openssh-warning
http://servercomputing.blogspot.jp/2012/08/Host-key-verification-failed-REMOTE-HOST-IDENTIFICATION-HAS-CHANGED.html
%HOME%\.ssh\known_hostsを開いて、たとえば、以下のような行を削除するとOKです。