Skip to main content

Multiple nodes on Vagrant

Recently I started working with Vagrant. Vagrant is a good tool that you can use for development. From this post I'm going to explain how to create multiple nodes on Vagrant project.
mkdir testProject
cd testProject
vagrant init

If you run above commands, it will create a Vagrant project for you. Now we have to do changes to the vagrant file. Your initial vagrant file will look like below.

You have to edit Vagrantfile add content like below.

Above sample vagrant file will create three nodes. Now run below command to start Vagrant virtual machines.
vagrant up

If you followed the instruction properly, you will get and output like below.

If you want to connect to master node, run below command.
vagrant ssh master
If you want to connect to slave1 node, run below command.
vagrant ssh slave1
What ever the machine you want to connect you just have to type vagrant ssh . Hope this will help you!