Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases production parity, and makes the “works on my machine” excuse a relic of the past.
Tools Needed to use vagrant:
In order to use vagrant, you should have following tools installed on your machine:
- Oracle Virtual Box
Once you have downloaded and installed all the above tools, you can use “Gitbash” to create virtual machines so easily using vagrant.
1. Open Gitbash:
Look for your programs and open Gitbash.
You will see a unix shell like prompt.
2. Create a directory where you want your virtual machines to be created:
3. Change to the directory by using cd command:
4. Initialize Vagrant by using “vagrant init”
5. Now open the Vagrantfile using your favourite editor like Vi, Vim, etc and make below changes (as per your requirement):
config.vm.box = “bento/centos-7.5”
config.vm.network “private_network”, ip: “192.168.33.14”
vb.memory = “2048”
vb.cpus = “2”
6. Now create the machine with Configuration mentioned in the “Vagrantfile” using “Vagrant up” command:
Abhinav-PC@DESKTOP-81JH4D6 MINGW64 /e/gitlab/lab1/vm1
$ vagrant up
Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Box ‘bento/centos-7.5’ could not be found. Attempting to find and install…
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default: Guest Additions Version: 5.2.18
default: VirtualBox Version: 6.1
==> default: Configuring and enabling network interfaces…
==> default: Mounting shared folders…
default: /vagrant => E:/gitlab/lab1/vm1
Congratulations !!! Your Virtual Machine is Ready to use.
7. Login to your virtual machine by using “vagrant ssh” command:
8. Set your machine’s hostname by using bellow command:
[root@localhost ~]# hostnamectl set-hostname git.unixcloudfusion.in
Your Machine is ready to use !!!
Happy Learning !!!