Up and running with Vagrant

- 6 mins

Summary:

Recently I was learning about linux environment and for practical learning I need to execute commands or install tools or changing complicated settings like user permission, firewall setup. Performaing this kind of operation on my own machine may led to generate unnecessary files or dangerous problems and I was looking for a different approach to learn and do the both works safely. Then I came up to a solution like Vagrant, which is perfectly suitable for my expectation. So I dig into it and found out that it is not only useful for experimental work but also for some other cases too. Let’s explore what we can do with vagrant and how it can be useful in your case.

Index


What is Vagrant

Vagrant is a mature and stable virtual environment builder. It can be used for building and distributing virtual environments. By environment I mean an OS (like Ubuntu) setup. You can create one environment (aka OS), configure with necessary tools and share the environment. People only need configuration file and when they boot it up they will get exact same environment with same tools in their machine.

Vagrant works on Linux, Mac and Windows. Vagrant also an open source project (Github).


Use cases


Installation

	vagrant init ubuntu/bionic64

Here vagrant init initializes a vagrant file with ubuntu/bionic64 ubuntu 18 64 bit box. You can search and use existing boxes from here. You can also build your own box and share here. This will create a new file named Vagrantfile in your directory.

	vagrant up

This may take few seconds to an hour based on your internet connection speed.

	vagrant ssh
	vagrant halt

This will completely shuts down the running machine vagrant is managing (source). Or this command

	vagrant suspend

This will not shut down rather just suspend the machin vagrant is managing it. A suspend effectively saves the exact point-in-time state of the machine, so that when you resume it later, it begins running immediately from that point, rather than doing a full boot (source).


How it works

Technology behind vagrant require three basic things:

Box
We’ve already discussed about box in Step 3 of Installation section. You can publish or find existing boxes from here. Box is a packaged virtual environment.

Provider
Provider is the location in which virtual environment(Box) runs. It has two types local and remote.

Local provider includes- VirtualBox, VMWare.

Remote provider includes- Cloud provider like AWS, Digital Ocean

Also an special case Docker can be used as a provider.

Provisioner
To setup we require a tool which is called here a provisioner. It can be a simple shell script, but some advanced tools like- Ansible, Chef, Puppet also can be used.


Resources

To learn more about Vagrant use following resources-


Conclusion

So this is my current understanding of vagrant. Feel free to correct me if I did any mistake here or need to add anything.


comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora