![Wie kann ich eine andere Vagrant-Maschine bereitstellen?](https://rvso.com/image/1414662/Wie%20kann%20ich%20eine%20andere%20Vagrant-Maschine%20bereitstellen%3F.png)
hashicorp/precise32
Ich habe den Abschnitt „Erste Schritte“ der Vagrant-Dokumentation befolgt und erfolgreich eine virtuelle Box-Maschine mit dem Box-Image gestartet
vagrant init hashicorp/precise32
vagrant up
Jetzt möchte ich eine neue 64-Bit-Ubuntu-Box erstellen. Ich habe erfolgreich eine neue Box hinzugefügt
$ vagrant box list
chef/ubuntu-13.10 (virtualbox, 1.0.0)
hashicorp/precise32 (virtualbox, 1.0.0)
Es wird jedoch vagrant up
nur die vorhandene Hashicorp/Precise32-Box angezeigt.
Welcher Abschnitt der Dokumentation bezieht sich auf das Erstellen einer zweiten Maschine? Muss ich hierfür VagrantFile trennen?
Antwort1
Sie können die vorhandene Vagrant-Datei bearbeiten und ein weiteres Feld hinzufügen.
Als Beispiel:
# 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
Dies ist ein Abschnitt aus einer Vagrant-Datei, die mitvagrant init
Die automatisch erstellte Box "base" wurde auskommentiert und zwei neue Boxen hinzugefügt. Um diese Boxen aufzurufen, können Sie vagrant up [boxname]
beispielsweise verwendenvagrant up centos6
Wenn Sie das Argument weglassen und nur ausführen vagrant up
, wird die Liste mit allen Boxen in der Reihenfolge angezeigt, in der sie in der Vagrant-Datei definiert sind.
Sie können den aktuellen Status der Boxen im Vagrantile wie folgt überprüfen 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`.