-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Infrastructure as Code Cookbook
By :

The VirtualBox Guest Additions are a set of drivers and applications to be deployed on a virtual machine to have better performance and enable features such as folder sharing. While it's possible to include the Guest Additions directly in the box, not all the boxes you'll find have it, and even when they do, they can be outdated very quickly.
The solution is to automatically deploy the VirtualBox Guest Additions on demand, through a plugin.
The downside to using this plugin is that the Vagrant box may now take longer to boot, as it may need to download and install the right guest additions for the box.
To step through this recipe, you will need the following:
Follow these steps to enable VirtualBox Guest Additions in Vagrant:
vagrant-vbguest
plugin:$ vagrant plugin install vagrant-vbguest Installing the 'vagrant-vbguest' plugin. This can take a few minutes... Installed the plugin 'vagrant-vbguest (0.13.0)'!
$ vagrant plugin list vagrant-vbguest (0.13.0)
$ vagrant up […] Installing Virtualbox Guest Additions 5.0.26 […] Building the VirtualBox Guest Additions kernel modules ...done. Doing non-kernel setup of the Guest Additions …done.
config.vbguest.auto_update = false
if Vagrant.has_plugin?("vagrant-vbguest") then config.vbguest.auto_update = false end
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/xenial64" if Vagrant.has_plugin?("vagrant-vbguest") then config.vbguest.auto_update = false end end
Vagrant plugins are automatically installed from the vendor's website, and made available globally on your system for all other Vagrant environments you'll run. Once the virtual machine is ready, the plugin will detect the operating system, decide if the Guest Additions need to be installed or not, and if they do, install the necessary tools to do that (compilers, kernel headers, and libraries), and finally download and install the corresponding Guest Additions.
Using Vagrant plugins also extends what you can do with the Vagrant CLI. In the case of the VirtualBox Guest Addition plugin, you can do a lot of things such as status checks, manage the installation, and much more:
$ vagrant vbguest --status [default] GuestAdditions 5.0.26 running --- OK.
The plugin can later be called through Vagrant directly; here it's triggering the Guest Additions installation in the virtual machine:
$ vagrant vbguest --do install
Change the font size
Change margin width
Change background colour