LoginSignup
8
9

More than 5 years have passed since last update.

Vagrant チームメンバー用

Last updated at Posted at 2014-09-17

Vagrantをチームで利用するときに、配布したVagrantfileを使うメンバーが時折おきるトラブルをまとめました.

チーム運用の際にメンバーに共有するつもりで作ったので参考にしてくだい.

基本

まずは基本コマンドから説明します.
Vagrantfileファイルが置かれているディレクトリか、その下層のディレクトリで
vagrantコマンドが利用できます.

コマンド中の[name]は複数のVMがある時に指定するものです.

コマンド 説明
vagrant status [name] ステータス表示
vagrant suspend [name] サスペンド
vagrant up [name] 起動 (サスペンドからの復帰等)
vagrant halt [name] シャットダウン
vagrant reload [name] 再起動
vagrant destroy [name] イメージの削除
vagrant ssh [name] SSH接続

SSHの設定

sshのconfigを設定しておくと、幸せになれます.

vagrant ssh-configコマンドでconfigの雛形が出力してくれます.

この結果を~/.ssh/config等に書いてssh ${HOST}で接続できるようになります.

以下の出力結果の場合はssh defaultで繋がります.

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/foo/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes

トラブルシューティング

ホスト/ゲスト間で/vagrant以下のパーミッションが異なる

Windows環境の場合、ゲストOSがLinux環境だと共有フォルダでマウントしたディレクトリ以下が777のパーミッションになります.

根本解決にはなりませんがVagrantfileでマウントしたときのファイルとディレクトリのパーミッションが指定できます.

config.vm.synced_folder “./”, “/vagrant”, owner: ‘root’, group: ‘root’, mount_options: ['dmode=777', 'fmode=666']

/vagrantがマウントされない

ゲストOS上で/vagrantがマウントされない場合があります、
VirtualBox等のバージョンアップ等でマウントされなくなる様です.

この場合以下のコマンドをゲストOS上で実行することでマウントできるようになります.

sudo /etc/init.d/vboxadd setup

その後、念のためゲストOSを再起動するとマウントされると思います.
以下のコマンドをホスト側で実行すると再起動します.

vagrant reload

ちなみにマウントできない時のエラーは以下のような感じ

Failed to mount folders in Linux guest. This is usually beacuse
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device

ネットワークが使えなくなった

ゲストOSからグローバルへpingが通っていたものが、使えなくなることがあるようです.
vagrant reload等で再起動すれば直ったらしいですが、掴めていません.

windowsのノートPCでサスペンドからの復帰時に起きた事象です.

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9