Now that we have Vagrant installed on our machine, let's look at creating projects.
There are three different ways we can do this.
We can create a new project with a named base box and the location where the box can be downloaded.
If we don't already have it set up, we can create a new project with a named base box and we can create
a new project which will get the default base box name.
Let's look at how we can do this now.
While we are going to look at commands to initialize our vagrant projects in this section, these are
simple, quick ways to create a vagrant file with some values.
Pre-populated.
Vagrant file is a configuration file which defines how Vagrant should use the project operating system
to be used.
Virtual machines to be boot up synchronized folders, forwarded ports and so on.
All this information is kept in vagrant file.
So let's go ahead and talk about importing and using base boxes.
Each virtual machine starts with what Vagrant calls a base box.
This is a specially packaged version of an operating system with some specific configurations in place.
The number of configurations and packages installed on this packaged operating system is typically minimal,
containing only a few tools which allow it to communicate with Vagrant.
It is the job of end user to install and configure the additional software on our virtual machines using
provisioning tools.
So let's say we are in the directory we wish to convert into a new vagrant project.
For example, I'll create a directory which I'll name Lab, I'll type MK Dio Lab and change directory,
which is CD lab to be in this working directory.
If you are working in Windows environment, you could do the same and even use the same commands to
make new directory and change directory.
Now I can start typing vagrant related commands.
We'll type vagrant in it.
Hashicorp slash precise 64 and you can add the address for this box.
For example https vagrant cloud dot com backslash Hashicorp service slash hashicorp slash precise 64.
So this command runs the init sub command within vagrant and instructs vagrant to create a new project
with configuration to use the box named Hashicorp slash precise 64.
And if the box is not found to import the box located at https vagrant cloud dot com slash hashicorp
slash precise 64.
When the vagrant environment is booted for the first time, the name can be used within other new and
existing projects to refer to these particular bass box base boxes are downloaded and stored in a place
vagrant can access and reuse.
Of course, if you want to use another box, for example Santos Linux or Ubuntu, Linux or any other
box, you can find the name you need on Vagrant Cloud, which is located at https colon slash slash
app dot vagrant app dot com.
But for now let's use this particular box.
So after a bass box is downloaded, the screen will look as follows.
The initialization of new project creates a file named Vagrant file within our project folder, which
is in my case lab when we go to boot away Grant Virtual environment Vagrant looks for this configuration
file to determine what to do because everything related to the vagrant environment is either within
this file or the provisioning, which could be ssh ansible puppet or chef files.
Within our project, it's easy to maintain the environment under version control and share it with colleagues.
So let's open up the file named Vagrant file and take a look inside.
The vagrant configuration file is written in RGB, and the default vagrant file we get is primarily
common, illustrating some of the ways we can customize the file.
These comments are prefixed with the hash character.
There are only four lines which are not common within the file.
Let's look at them now.
The first line tells Vagrant that this is version two of the configuration object, so this line instructs
Vagrant to use the box named Precise 64.
So hashicorp slash precise 64.
If we are working with a new Vagrant project which uses a base box we haven't installed, we need a
mechanism for Vagrant to find and download the base box for us.
This next line tells Vagrant where it can download a copy of the box named Hashicorp slash precise 64
and when the VM is booted for the first time, if the base box is not found, then it will be downloaded
from the URL provided.
We'll see this in action once we boot the VMM for the first time.
This can either be a web address or a path to a file on the file system or network.
And finally, we tell Vagrant that the configuration has ended and it should stop processing the configuration
with this short command, which is.
And now let's recap.
First, we've created a working directory for our vagrant project.
We typed Dear Lab, then we changed directory by typing seed lab.
After that we've typed Vagrant in it the name of the box we wanted to use.
In our case it was SC Corp slash brew size 64, followed by the address where this box could be downloaded
from.
Next, we've taken a closer look at vagrant file.
We've removed four lines of this file.
Now, a small task for you.
First, you have to create a new folder for a new vagrant project, and in this folder type, the command,
which will create a new vagrant file containing the information about Santos seven box.
You don't have to specify the address for this box.
Just the box itself.
Please press pause here, and in a few seconds I'll show the answer for this simple task.
So the commands you had to use are as follows.
McDeere and the name of your work and folder, for example.
Santos, seven Seed Center, seven, and Vagrant Center slash seven.
The name for this box could be found on EBS dot Vagrant app dot com.