on
technology
- Get link
- X
- Other Apps
There can be numerous other requirements where you might use this component. I would urge you to remark your necessity on this blog with the goal that it can help other people also.
It is expected that you have Vagrant and Virtual Box previously installed. Presently, we should perceive how to create multiple VMs using vagrant:
Step 1: Open the terminal (Linux or Mac) or command prompt (Windows)
Step 2: Create a new directory for vagrant :
$ mkdir vagrant_multi_rude $ cd vagrant_multi_rude
Step 3: Initialize a new VagrantFile.
$ vagrant init
Step 4: Install a vagrant box. We are using “chef/centos-6.5”
$ vagrant box add chef/centos-6.5
Step 5: Update the Vagrant File as below:
# This defines the version of vagrant Vagrant.configure(2) do |config| # Specifying the box we wish to use config.vm.box = "chef/centos-6.5" # Adding Bridged Network Adapter config.vm.network "public_network" # Iterating the loop for three times (1..3).each do |i| # Defining VM properties config.vm.define "rude_vm#{i}" do |node| # Specifying the provider as VirtualBox and naming the VM's config.vm.provider "virtualbox" do |node| # The VM will be named as rude_vm{i} node.name = "rude_vm#{i}" end end end end
Step 6: Let’s start the rude_vms namely: rude_vm1, rude_vm2 and rude_vm3:
$ vagrant up
Congratulations! You have created three VMs using single vagrant file. You must be wondering how to use it. You can access it using ssh.
You can connect the VMs using the below host and port number:
rude_vm1 –> Host : 127.0.0.1 | Port : 2222
rude_vm2 –> Host : 127.0.0.1 | Port : 2200
rude_vm3 –> Host : 127.0.0.1 | Port : 2201
Step 7: Download putty (windows shh client) from here. Run the application and connect to the VMs.
Comments
Post a Comment