chef-solo とか vagrant とか

何故か引き籠りな土曜日。
とりあえず vagrant なソレを久々に弄ってみることに。とりあえずどっちを向いても CentOS みたいなので以下をナニするか。

以下なカンジ?

$ vagrant box add base http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box

URL 長い。そして download にも恐ろしく時間がかかるのだろうな。
とりあえずエントリ投入しといてその後の諸々は別途ということにて。

完了

[vagrant] Downloading with Vagrant::Downloaders::HTTP...
[vagrant] Downloading box: http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...

結構時間かかりました。次は vagrant init か。

$ vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ ls
Vagrantfile

で、Vagrantfile を以下にして

Vagrant::Config.run do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "base"
  config.vm.network :hostonly, "192.168.50.12"

vagrant up すれば良い模様。起動したら vagrant ssh で接続できると。

$ vagrant up
[default] Importing base box 'base'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.

起動しないな、って思ってたら失敗。

[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.

つうかマシンリソースの問題だと思うのですが動作が猛烈に遅いな。今 vagrant halt 中なんですが何時間かかるんだ、という勢い。つうか i386 なイメージじゃないとアレだった模様。
一旦 base を remove して

$ vagrant box remove base
[vagrant] Deleting box 'base'...

再度取得しなおし。

$ vagrant box add base http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130309.box

て、vagrant は gem での導入が廃止とかってリンクを発見orz

$ apt-cache search vagrant
vagrant - Tool for building and distributing virtualized development environments

うぶんつだと 1.0.3-1 って出ますね。ちなみに gem なソレは以下。

$ vagrant -v
Vagrant version 1.0.7

とりあえず gem な vagrant を uninstall して apt-get で導入。

$ gem uninstall vagrant
Remove executables:
        vagrant

in addition to the gem? [Yn]  
Removing vagrant

でも apt-get で vagrant 入れたらパケジな ruby が入るな。そもそも vagrant 自体が rubygem に依存してる風に見える。apt-get update して再度確認してみるか。でもおそらく基本的には変わらないはず。
で、本家をアレしてみたら以下なナニを発見。

なんじゃこれは。とりあえず取得して

$ wget http://files.vagrantup.com/packages/67bd4d30f7dbefa7c0abc643599f0244986c38c8/vagrant_x86_64.deb

dpkg -i なのか。元ネタは以下です。

おそらくこの vagrant 使うと EC2 なナニも、ってヤツだな。で、いきなりオトして dpkg -i したんですが大丈夫なのか。

$ vagrant -v
Vagrant version 1.1.2

ファイルもっかい取得して、とか面倒だなぁ。
こんどは x86_64 なソレで良いのかどうか。CentOS-6.4-x86_64-v20130309.box なナニを再度 kickoff してます。

終わった模様

vagrant up してみると速攻でコマンド終了。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...

vagrant ssh してみます。大丈夫なのかなぁ。って駄目でした。

$ vagrant ssh
ssh_exchange_identification: Connection closed by remote host

リトライしてみます。

$ rm -rf Vagrantfile*

で、デフォルトで試験してみたのですが挙動変わらず。つうか現状の状態がよく分からない。でも vagrant ssh で接続ができるわけではない、はず。
ええと、動作しているであろう状態から以下、ってレスポンスってことは

$ vagrant ssh
ssh_exchange_identification: Connection closed by remote host

接続先の設定が微妙なのかどうか。いったん destroy せえとか書いてるな。

$ vagrant destroy
Are you sure you want to destroy the 'default' VM? [y/N] y
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...

で、再度 up しろとのこと。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'base'...
[default] No guest additions were detected on the base box for this VM! Guest
additions are required for forwarded ports, shared folders, host only
networking, and more. If SSH fails on this machine, please install
the guest additions and repackage the box to continue.

This is not an error message; everything may continue to work properly,
in which case you may ignore this message.
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[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] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.

うーん、ここから、なんスけど。つうか何故にここまでハマるのかorz
なんでしょ、前回 (?) もこれ系のナニでハマリまくって披露困憊になってしまった記憶がアレだったりするんですがどうしたものやら。
で、色々確認してるに

  config.vm.network :bridged

ってヤッとけ、的ドキュメントを見たのでリセットしてみることに。
なんとなく端末リソースの問題じゃないような気がしてるんですがどうなんだろ。