This is an old revision of the document!
Multiple Boxes
Vagrant is often used to manage MANY virtual machines. Therefore we need to be able to provide many customized configurations. In the following example, you can see 2 virtual box configurations
MultiBox Configuration
Vagrant.configure("2") do |config| config.ssh.insert_key = true config.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "1534" end config.vm.define "ainsible" do |app| app.vm.box = "centos/7" app.ssh.username = 'root' app.ssh.password = 'vagrant' app.vm.network "private_network", ip: "192.168.10.2" app.vm.network "public_network" # app.ssh.forward_agent = true app.ssh.insert_key = true end config.vm.define "app1" do |app| app.vm.hostname = "orc-app1.dev" app.vm.box = "centos/7" app.ssh.username = 'root' app.ssh.password = 'vagrant' app.vm.network "private_network", ip: "192.168.10.3" end
The first part of the configuration is the general configuration for all boxes. As you can see, we have enabled GUI for all machines and we have enabled 1534 MBs of Virtual memory (RAM). The next part is configuration for a box called: ainsible and the other for a box called: app1
Possible Errors
In case you receive the following error:
Authentication-Error
==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: root default: SSH auth method: private key default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying...
Assure that the password for the user (in our case root) is the same as the vagrant file AND ensure that the rootlogin is enable and the password authentication is also enabled.