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

Infrastructure as Code Cookbook
By :

Vagrant supports many configuration options through the Vagrantfile. Here are the most useful ones for daily use.
To step through this recipe, you will need the following:
Here are some possible customizations for your Vagrant Virtual Machine.
If you want to specify the VM name right from Vagrant, just add the following:
config.vm.hostname = "vagrant-lab-1"
This will also add an entry with the hostname to the /etc/host
file.
You may be using a slow internet connection, or you know you do want to use your current installed box, or maybe you're in a hurry and just want to get the job done; you can just remove the option to check for a new version of the box at startup by adding the following:
config.vm.box_check_update = false
If you know you want to use a specific version of the box (maybe for debugging purposes or compliance) and not the latest, you can simply declare it as follows:
config.vm.box_version = "2.2.9"
A useful feature is to display some basic but relevant information to the user launching the Vagrant box, such as usage or connection information. Don't forget to escape the special characters. As it's Ruby, you can access all available variables, so the message can be even more dynamic and useful to the user:
config.vm.post_up_message = "Use \"vagrant ssh\" to log into the box. This VM uses #{vm_cpus} CPUs and #{vm_memory}MB of RAM."
Vagrant is updated quite often, and new features are added regularly. A good practice, if you use a feature that is known to work only after a specific version, is to declare it in the Vagrantfile, so people with an older version know they have to update:
Vagrant.require_version ">= 1.8.0"
Change the font size
Change margin width
Change background colour