Vagrant is a tool for building and managing virtual machine environments in a single workflow
Vagant will help you to craete env in your local. for that you need vagrant and virtual box on your local to run vagrant.
Install the vagrant on your local from below urls :-
Vagrant : https://www.vagrantup.com/downloads.html
Vagrant box : https://app.vagrantup.com/boxes/search
Oracle VirtualBox : https://www.virtualbox.org/wiki/Downloads
Command Prompt :-
$ vagrant -v
$ vagrant box add ubuntu/trusty64
$ vagrant init ubuntu/trusty64
$ vagrant up
- config.vm.box = "hashicorp/precise64"
config.vm.network "forwarded_port", guest: 80, host: 8089
config.vm.network "private_network", type: "dhcp"
config.vm.network "private_network", ip: "84.0.0.10"
- Type 1
config.vm.provider "virtualbox" do |vb|
v.memory = 2048
v.cpus = 2
v.gui = true
v.name = "TEST!"
end
Example -
- v.memory = RAM you want to use in VM 1024 = 1GB
- v.cpus = core no to cpu
- v.gui = add only if you want to open gui mode if you want to use then also install gui packge in ubuntu
sudo apt-get install --no-install-recommends lubuntu-desktop
-
v.name = any name of your wish.
-
TYPE 2
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50", "--cpus", "1"]
vb.memory = 2048
end
- Vagrant.configure("2") do |config|
config.vm.define "lb1" do |lb|
lb.vm.box = "ubuntu/trusty64"
end
config.vm.define "web1" do |appserver1|
appserver1.vm.box = "ubuntu/trusty64"
end
config.vm.define "web2" do |appserver2|
appserver2.vm.box = "ubuntu/trusty64"
end
-
end
-
case 1 = install using script
config.vm.provision :shell, :path => "bootstrap.sh"
- case 2 = install using cmd or inline
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y apache2
SHELL
Vagrant.configure("2") do |config|
config.vm.define "lb" do |lb|
lb.vm.box = "ubuntu/trusty64"
lb.vm.network "private_network", ip: "84.0.0.10"
lb.vm.hostname = "lb.com"
lb.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y nginx
SHELL
end
config.vm.define "app1" do |app1|
app1.vm.box = "ubuntu/trusty64"
app1.vm.network "private_network", ip: "84.0.0.20"
app1.vm.hostname = "app1.com"
app1.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y apache2
SHELL
end
config.vm.define "app2" do |app2|
app2.vm.box = "ubuntu/trusty64"
app2.vm.network "private_network", ip: "84.0.0.30"
app2.vm.hostname = "app2.com"
app2.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y apache2
SHELL
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50", "--cpus", "1"]
vb.memory = 2048
end
- Open Ip on Browser 84.0.0.10
- Harish Chander Dalal - Initial work - PurpleBooth