うえきのブログ

妙高市に住んでいるサーバエンジニアのブログです

Vagrant-AWSでうまくいかない時の調べ方

環境変数 VAGRANT_LOG を設定する

$ export VAGRANT_LOG=debug
$ vagrant up

すると詳細な動作ログを読むことができるので原因特定できるはず。

"[default] Waiting for SSH to become available..."で止まる

AWSプロバイダーを使って vagrant up した時に"[default] Waiting for SSH to become available..."で止まってしまうのは

ERROR warden: Error occurred: There are errors in the configuration of this machine.
Please fix the following errors and try again:

vm:
* The host path of the shared folder is missing: /Users/username/aws/cookbooks

ということでVagrantfileのあるディレクトリ直下にcookbooksディレクトリが存在しないため mkdir すれば直る。

mkdir -p '/vagrant' が失敗する

INFO interface: error: The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p '/vagrant'
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mkdir -p '/vagrant'

Amazon Linux の /etc/sudoers でsudoにTTYを要求するため。失敗メッセージが表示されたら

$ vagrant ssh

してEC2インスタンスにログインし、requirettyの行をコメントアウトすればOK。

$ sudo visudo

#Defaults    requiretty

EC2インスタンスをexitしたら改めてプロビジョニングを実行する。

$ vagrant provision

Vagrant でEC2にChef-SoloするときのChefはいつインストールしたらいいんだ?

The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.

vagrant provision する前にvagrant sshして、必要パッケージを手作業で yum install してあげるしかないのかな・・・

$ vagrant ssh

$ sudo yum -y install git rubygems make gcc ruby-devel
$ sudo gem install chef --no-ri --no-rdoc
$ exit

$ vagrant provision