- Setup – download and install Vagrant – Installing Vagrant on CentOS 7.
- Configure – Create a single file i.e. ‘Vagrantfile’, to specify the specs for the virtual machine you want Vagrant to spawn, and run vagrant init <box-to-use>;
- Work – simply run ‘vagrant up‘, and a clean development environment will be there.
Some necessary vocabulary
technically Vagrant is itself just a wrapper or management utility on top of virtualization software such as VirtualBox, KVM, or VMware, and around configuration management software such as Chef, Puppet, Ansible, etc. The biggest obstacle newbies face while exploring Vagrant is the vocabulary (which is the case with almost all the tech docs). Here are the main terminologies one needs to be clear about, to get easy with Vagrant:
- Providers providers are the basic virtualization technology Vagrant use, as stated above Vagrant itself is just a utility above theses softwares e.g. VirtualBox, KVM, or VMware, etc. The initial Vagrant only supported a single provider i.e. VirtualBox, in later releases (1.1) support for KVM, VMWare, Hyper-V, etc was also added. Since version 1.6, Vagrant also support Docker. Since version 1.6, Vagrant natively supports Docker containers, which in some cases can serve as a substitute for a fully virtualized operating system.
- Provisioners: are the softwares Vagrant use to configure and provision the VMs. Vagrant supports all the mainstream configuration management tools such as Puppet, Ansible, or Chef, etc. The various supported provisioning softwares – https://www.vagrantup.com/docs/provisioning/
- Boxes – this term must be disturbing you in almost every post you read about Vagrant. Box (Vagrant Box) is simply a configuration for spawning virtual machines using Vagrant i.e in conventional sense it’s just a template for creating a VM. We can set machine configuration ourselves, as per need, or can simply use any of the publicly available boxes (templates). The vagrant box command utility is available for managing boxes – official docs for vagrant box command. There’s public Vagrant box catalog ‘Discover Vagrant Boxes‘ – makes it easy to search and use Vagrant boxes created by the community. Also check this ‘vagrant.es‘, the website lists boxes, people have been nice enough to share publicly. For more – official vagrant box docs.
- Vagrantfile – where we specify the configuration for vagrant, about what type of virtual machine we want, once set, executing vagrant up will have our clean development environment up and running. A single Vagrantfile is required per project. Usually there must be Vagrantfile in the directory you’ll be executing vagrant up (or other vagrant command) – but in case it didn’t find any the, Vagrant will climb up the directory tree to find one. For example: If you executed vagrant in /home/ahmed/projects/foo, it look for a Vagrantfile in the following order, starting from current directory and moving up, until it finds one: