Vagrant – VagrantFile

VagrantFile is in ruby syntax. This is configuration that is used when vagrant creates vms. If no directory is given vagrant will mount vagrant folder as shared folder between host and container/vm .

To setup custom sync folder

Vagrant.configure("2") do |config| = 'centos/7'
  # configures synced folder
  config.vm.synced_folder "./content", "/vagrant"

To setup multi VMs in one vagrant file

Vagrant.configure("2") do |config|

  config.vm.define "web" do |web| = "centos/7"

  config.vm.define "db" do |db| = "centos/7"

To create and start up VMs

cd to the folder you hace your VagrantFile in and run the following command:

vagrant up

These are really simple configuration files but can get complex fast with network / provider config. Virtualbox is the easiest to use. Libvirt seems to take the most tweaking especially with networks.

Leave a comment

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see