If we would want to spin up virtual machine based on Centos 7 we could i.e. ![]() Vagrant init kbi/ubuntu16.04 creates a Vagrantfile in your current working directory, the Vagrantfile contains the specification of your virtual machines, networks and other configurations, the Image "kbi/ubuntu16.04" will be used as the Base Image used for the virtual machine in this case. So what do the different Vagrant commands do? The vagrant init kbi/ubuntu16.04 & vagrant up commands will download a Image based on Ubuntu16.04 that is roughly 605 MB ins size, this might take a while, depending on your Connection.Īlso the Images used in the Examples here are all built by myself and are based on these Packer Templates, you can find many different Base Images on Vagrant Cloud. ![]() Now that we installed Vagrant and VirtualBox it is time to test our installation to ensure everything works as expected, for that purpose we create an empty folder for our Vagrant Test and run a few Vagrant commands in it to spin up a virtual machine running Ubuntu 16.04, connect to it via SSH to ensure it works as expected and destroy it afterwards. If you ar on Mac, you can use Homebrew to install Vagrant and Virtualbox via brew cask install vagrant virtualbox and if you are on Windows, you can use these installers. This will open an information window that looks like this, where you can find the version of your VirtualBox installation. You can check the version of an installed VirtualBox by starting VirtualBox and navigating the the top menu Help -> About VirtualBox. on Ubuntu you can run the command sudo apt install virtualbox to install VirtualBox. check here to ensure a specific version is supported) on most linux distributions this can be done easily via package management i.e. Vagrant supports multiple providers, like VirtualBox, Hyper-V, VMware (Fusion and Workstation), Docker or libvirt (via third party Plugin), but for sake of simplicity this Article will stick to VirtualBox as it is the default provider and can be used on Windows, Linux and Mac.įirst we need to install VirtualBox and Vagrant, head over to the Vagrant Download Page, download and install the Package matching your Operating System and Architecture (Ubuntu/Linux Mint users can use the Debian package).Īfter installing Vagrant we need to install a supported Version of VirtualBox (at the Time of this writing 4.0.x, 4.1.x, 4.2.x, 4.3.x, 5.0.x, 5.1.x, and 5.2.x. vagrant destroy & vagrant up.īy doing this every so often you can ensure that your whole deployment works as intended and you are not messing with some weird state that you created while developing and testing something that did not work out. Vagrant is a platform independent way for spinning up and managing virtual machines and development environments.īy using Vagrant other people are able to quickly spin up a local virtual machine environment that looks and behaves just like yours, as a result the works for me issues are becoming less, Vagrant can also be used to quickly destroy and rebuild virtual machines used for development and testing and to apply Test Playbooks on them.ĭestroying your multi VM development environment, recreating it and deploying a Playbook onto it can easily be done by running just two commands. Why use Vagrant for testing and development? If you are already familiar with the baisics of Vagrant and want to jump right to the Juicy bits you can skip over to here. In this I article describe why and how I use Vagrant for testing while developing new Ansible roles and how you can make your live a little easier with Vagrant and Ansible. Vagrant is a tool used for building, destroying, recreating and managing virtual machines and development environments with a focus on automation, combined with the Ansible Provisioner it can be used for testing and developing Ansible Playbooks and roles. If you are interested in testing your Ansible roles and a better development experience, check out Molecule!, that said, please feel free to read this article anyway, maybe you can get something out of it ^^. ![]() ![]() UPDATE 07/2021: At the time of this update this Article is 3 Years old, A lot has happened in the Ansible Space, and I would no longer recommend the Methods described here. How to use Vagrant for Ansible role testing and development
0 Comments
Leave a Reply. |