Virtual Event
Join us for the next HashiConf Digital October 12-15, 2020 Register for Free

Getting Started

Initialize a Project Directory

The first step in configuring any Vagrant project is to create a Vagrantfile. The Vagrantfile allows you to:

  • Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.

  • Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.

»Create a directory

Make a new directory for the project you will work on throughout these tutorials.

$ mkdir vagrant_getting_started

Move into your new directory.

$ cd vagrant_getting_started

»Initialize the directory

Vagrant has a built-in command for initializing a directory, vagrant init, which can take a box name and URL as arguments. Initialize the directory and specify the hashicorp/bionic64 box.

$ vagrant init hashicorp/bionic64

You now have a Vagrantfile in your current directory. Open the Vagrantfile, which contains some pre-populated comments and examples. In following tutorials you will modify this file.

The Vagrantfile is meant to be committed to version control with your project, if you use version control. This way, every person working with that project can benefit from Vagrant without any upfront work.

You have now initialized your first project directory. To set up Vagrant for an existing project you would run vagrant init in a pre-existing directory. Continue to the next tutorial to specify a box for your project.