目次
新規のvagrantを立ち上げるときに、別のOSのboxファイルを使って構成しようとしたときにエラーが出た話
事象
Vagrantを新規で立ち上げる時に、別のOSのboxファイルを使って構成しようとしたときにエラーが発生
エラー内容
default: SSH address: 127.0.0.1:11020 default: SSH username: vagrant default: SSH auth method: private key Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly, as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
また、vagrant portコマンドで以下のエラーを出力
There are errors in the configuration of this machine. Please fix the following errors and try again: vm: * A box must be specified. * Forwarded port definitions require a "host" and "guest" value * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 * Ports to forward must be 1 to 65535 shell provisioner: * Shell provisioner `args` must be a string or array.
原因
どうやら、OSをboxファイルから持ってきたときの元のSSH設定が既にあって、それが新規vagrant向けに設定したSSHの設定と競合していたらしい・・?
解決策
vagrantfileに以下を追記
config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--cableconnected1", "on"] end
–cableconnected<1-N> on|off:
実際にあるかのように、仮想ネットワークカードのケーブルを抜くことができます。
これは、仮想マシン内の特定のソフトウェアコンポーネントをリセットするための役に立つかもしれません。
コメントを書く