我有以下 vagrantfile,它指定了 2 台机器 - 前端和后端框。
Vagrant.configure(2) do |config|
config.vm.box = "frontend"
config.vm.network "private_network", ip: "192.168.0.5"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "4096"
end
config.vm.communicator = "winrm"
config.vm.provision "shell", path: "Provision.ps1"
config.vm.define "db" do |db|
db.vm.box = "backend"
db.vm.network "private_network", ip: "192.168.0.10"
db.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "4096"
end
db.vm.communicator = "winrm"
db.vm.provision "shell", path: "ProvisionRemote.ps1"
end
end
当我键入 vagrant up 时,根据 Multi-Machine 文档,它应该首先启动前端盒并运行 Provision.ps1,然后启动后端盒并在其上运行 ProvisionRemote.ps1(由外而内)。
然而,发生的事情是后端盒首先启动,然后它尝试在其上运行 Provision.ps1(用于前端盒)。
Bringing machine 'db' up with 'virtualbox' provider...
==> db: Importing base box 'backend'...
==> db: Matching MAC address for NAT networking...
==> db: Checking if box 'backend' is up to date...
==> db: Setting the name of the VM: RemoteBox_db_1459513634410_78500
==> db: Clearing any previously set network interfaces...
==> db: Preparing network interfaces based on configuration...
db: Adapter 1: nat
db: Adapter 2: hostonly
db: Adapter 3: hostonly
==> db: Forwarding ports...
db: 5985 => 55985 (adapter 1)
db: 5986 => 55986 (adapter 1)
==> db: Running 'pre-boot' VM customizations...
==> db: Booting VM...
==> db: Waiting for machine to boot. This may take a few minutes...
db: WinRM address: 127.0.0.1:55985
db: WinRM username: vagrant
db: WinRM transport: plaintext
==> db: Machine booted and ready!
==> db: Checking for guest additions in VM...
db: The guest additions on this VM do not match the installed version of
db: VirtualBox! In most cases this is fine, but in rare cases it can
db: prevent things such as shared folders from working properly. If you see
db: shared folder errors, please make sure the guest additions within the
db: virtual machine match the version of VirtualBox you have installed on
db: your host and reload your VM.
db:
db: Guest Additions Version: 4.3.28
db: VirtualBox Version: 5.0
==> db: Configuring and enabling network interfaces...
==> db: Mounting shared folders...
db: /vagrant => E:/_workingSource/project/env/
==> db: Running provisioner: shell...
db: Running: Provision.ps1 as c:\tmp\vagrant-shell.ps1
为什么要这样做?我究竟做错了什么?