Create and provision desired OS using Vagrant and Virtualbox This can be used for cross platform testing like on Windows, Linux (Ubuntu, Centos, RHEL etc.). Build your environment quickly then deploy and test.
Vagrant is a tool to help create and provision VirtualBox machines.Few of the reasons for using it would be:
- The development environment can be isolated from all the other junk that accumulates on primary computer.
- The development environment can be tuned to match a production server environment as closely as possible.
- Provisioning scripts define the machine configuration in code. This means the configuration is repeatable and versionable.
Everything has been tested on Ubuntu 14.04 LTS. All below installation instructions are from Ubuntu. Instructions will change for different OS version. Feel free to create pull request (PR) for that or ask me.
-
First we need to install Vagrant
sudo apt-get install vagrant
This will install virtual box 4.2 and other dependencies like ruby (in case you don’t have already) We can verify the installation using command :
$vagrant -v
-
Now that we have Vagrant,VirtualBox,Ruby installed. Lets try and provision a vm. We would try and install Ubuntu 12.04 32 bit on virtual box using vagrant. Choose a location where you need to put your Vagrant file, I made a folder myVMs in home The command :
$ vagrant init precise64 http://files.vagrantup.com/precise64.box
-
Now the main part about configuring Vagrantfile You can change following two lines as per the required OS (be careful)
........ ....... # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "precise32" # The url from where the 'config.vm.box' box will be fetched if it # doesn't already exist on the user's system. config.vm.box_url = "http://files.vagrantup.com/precise32.box" ........ ........
Use this VAGRANT_BOX_URL for getting ready to run vagrant boxes.
Example:
OS (name) URL Windows 7 http://vagrantboxes.devopslive.org/windows-7-enterprise-i386.box OpenSuse https://s3.amazonaws.com/circlejtp/OpenSuseVagrant/OpenSuse12_1x64_July14.box
Following commands are very handy to play with Vagrantfile
$vagrant box add name url
$vagrant box list
vagrant up
vagrant destroy
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D