![如何配置另一台流浪機器?](https://rvso.com/image/1414662/%E5%A6%82%E4%BD%95%E9%85%8D%E7%BD%AE%E5%8F%A6%E4%B8%80%E5%8F%B0%E6%B5%81%E6%B5%AA%E6%A9%9F%E5%99%A8%EF%BC%9F.png)
我已按照 vagrant 文件的“入門”部分進行操作,並使用盒子hashicorp/precise32
映像成功啟動了虛擬盒子機
vagrant init hashicorp/precise32
vagrant up
現在我想建立一個新的 64 位元 ubuntu 盒子。我已經成功地添加了一個新盒子
$ vagrant box list
chef/ubuntu-13.10 (virtualbox, 1.0.0)
hashicorp/precise32 (virtualbox, 1.0.0)
但vagrant up
只會顯示現有的 hashcorp/precise32 框。
文件的哪一部分與建立第二台機器相關?我需要為此分離 VagrantFile 嗎?
答案1
您可以編輯現有的 Vagrantfile,並新增另一個方塊。
舉個例子:
# Every Vagrant virtual environment requires a box to build off of.
# config.vm.box = "base"
config.vm.define :centos6 do |node1|
node1.vm.hostname = 'centos.internal'
node1.vm.box = 'centos-65-x64-virtualbox-nocm.box'
node1.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box'
node1.vm.network :private_network, ip: "10.200.0.10"
end
config.vm.define :precise do |node2|
node2.vm.hostname = "precise"
node2.vm.box = 'ubuntu-server-12042-x64-vbox4210-nocm.box'
node2.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box'
node2.vm.network :private_network, ip: "10.200.0.11"
end
這是取自使用建立的 Vagrantfile 的部分vagrant init
自動建立的框「base」已被註解掉,並新增了兩個新框。為了調出這些框,您可以使用vagrant up [boxname]
,例如vagrant up centos6
如果省略參數,然後執行vagrant up
,所有方塊清單都會依照 Vagrantfile 中定義的順序顯示。
您可以使用以下命令檢查 Vagrantile 中框的目前狀態vagrant status
:
$ vagrant status
Current machine states:
centos6 not created (vmware_fusion)
precise not created (vmware_fusion)
This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.