WEBVTT

00:06.330 --> 00:12.540
Now that we have Vagrant installed on our machine, let's look at creating projects.

00:12.540 --> 00:15.380
There are three different ways we can do this.

00:15.390 --> 00:23.160
We can create a new project with a named base box and the location where the box can be downloaded.

00:23.160 --> 00:31.320
If we don't already have it set up, we can create a new project with a named base box and we can create

00:31.320 --> 00:36.080
a new project which will get the default base box name.

00:36.090 --> 00:39.000
Let's look at how we can do this now.

00:39.000 --> 00:47.340
While we are going to look at commands to initialize our vagrant projects in this section, these are

00:47.340 --> 00:52.710
simple, quick ways to create a vagrant file with some values.

00:52.710 --> 00:54.060
Pre-populated.

00:54.060 --> 01:03.360
Vagrant file is a configuration file which defines how Vagrant should use the project operating system

01:03.360 --> 01:04.380
to be used.

01:04.380 --> 01:11.580
Virtual machines to be boot up synchronized folders, forwarded ports and so on.

01:11.580 --> 01:14.940
All this information is kept in vagrant file.

01:14.940 --> 01:20.550
So let's go ahead and talk about importing and using base boxes.

01:20.550 --> 01:26.700
Each virtual machine starts with what Vagrant calls a base box.

01:26.700 --> 01:34.320
This is a specially packaged version of an operating system with some specific configurations in place.

01:34.320 --> 01:42.390
The number of configurations and packages installed on this packaged operating system is typically minimal,

01:42.390 --> 01:47.400
containing only a few tools which allow it to communicate with Vagrant.

01:47.400 --> 01:56.400
It is the job of end user to install and configure the additional software on our virtual machines using

01:56.400 --> 01:57.990
provisioning tools.

01:57.990 --> 02:04.950
So let's say we are in the directory we wish to convert into a new vagrant project.

02:04.950 --> 02:15.600
For example, I'll create a directory which I'll name Lab, I'll type MK Dio Lab and change directory,

02:15.600 --> 02:20.670
which is CD lab to be in this working directory.

02:20.670 --> 02:28.500
If you are working in Windows environment, you could do the same and even use the same commands to

02:28.530 --> 02:31.350
make new directory and change directory.

02:31.380 --> 02:35.670
Now I can start typing vagrant related commands.

02:35.670 --> 02:38.520
We'll type vagrant in it.

02:38.550 --> 02:46.860
Hashicorp slash precise 64 and you can add the address for this box.

02:46.860 --> 02:57.900
For example https vagrant cloud dot com backslash Hashicorp service slash hashicorp slash precise 64.

02:57.900 --> 03:07.200
So this command runs the init sub command within vagrant and instructs vagrant to create a new project

03:07.200 --> 03:14.040
with configuration to use the box named Hashicorp slash precise 64.

03:14.040 --> 03:24.030
And if the box is not found to import the box located at https vagrant cloud dot com slash hashicorp

03:24.030 --> 03:26.550
slash precise 64.

03:26.550 --> 03:34.440
When the vagrant environment is booted for the first time, the name can be used within other new and

03:34.440 --> 03:43.740
existing projects to refer to these particular bass box base boxes are downloaded and stored in a place

03:43.810 --> 03:46.890
vagrant can access and reuse.

03:46.950 --> 03:56.250
Of course, if you want to use another box, for example Santos Linux or Ubuntu, Linux or any other

03:56.250 --> 04:06.480
box, you can find the name you need on Vagrant Cloud, which is located at https colon slash slash

04:06.480 --> 04:09.930
app dot vagrant app dot com.

04:09.930 --> 04:13.620
But for now let's use this particular box.

04:13.620 --> 04:19.380
So after a bass box is downloaded, the screen will look as follows.

04:19.380 --> 04:28.560
The initialization of new project creates a file named Vagrant file within our project folder, which

04:28.560 --> 04:36.780
is in my case lab when we go to boot away Grant Virtual environment Vagrant looks for this configuration

04:36.780 --> 04:44.550
file to determine what to do because everything related to the vagrant environment is either within

04:44.550 --> 04:52.860
this file or the provisioning, which could be ssh ansible puppet or chef files.

04:52.860 --> 05:00.900
Within our project, it's easy to maintain the environment under version control and share it with colleagues.

05:00.900 --> 05:05.700
So let's open up the file named Vagrant file and take a look inside.

05:06.050 --> 05:14.390
The vagrant configuration file is written in RGB, and the default vagrant file we get is primarily

05:14.390 --> 05:19.690
common, illustrating some of the ways we can customize the file.

05:19.700 --> 05:24.270
These comments are prefixed with the hash character.

05:24.290 --> 05:29.870
There are only four lines which are not common within the file.

05:29.900 --> 05:31.650
Let's look at them now.

05:31.670 --> 05:40.130
The first line tells Vagrant that this is version two of the configuration object, so this line instructs

05:40.130 --> 05:45.090
Vagrant to use the box named Precise 64.

05:45.110 --> 05:49.070
So hashicorp slash precise 64.

05:49.100 --> 05:57.710
If we are working with a new Vagrant project which uses a base box we haven't installed, we need a

05:57.710 --> 06:03.860
mechanism for Vagrant to find and download the base box for us.

06:03.890 --> 06:13.610
This next line tells Vagrant where it can download a copy of the box named Hashicorp slash precise 64

06:13.610 --> 06:21.050
and when the VM is booted for the first time, if the base box is not found, then it will be downloaded

06:21.050 --> 06:23.390
from the URL provided.

06:23.390 --> 06:28.520
We'll see this in action once we boot the VMM for the first time.

06:28.550 --> 06:36.000
This can either be a web address or a path to a file on the file system or network.

06:36.020 --> 06:44.840
And finally, we tell Vagrant that the configuration has ended and it should stop processing the configuration

06:44.840 --> 06:46.640
with this short command, which is.

06:46.640 --> 06:48.930
And now let's recap.

06:48.950 --> 06:54.080
First, we've created a working directory for our vagrant project.

06:54.080 --> 07:02.030
We typed Dear Lab, then we changed directory by typing seed lab.

07:02.060 --> 07:08.660
After that we've typed Vagrant in it the name of the box we wanted to use.

07:08.660 --> 07:18.170
In our case it was SC Corp slash brew size 64, followed by the address where this box could be downloaded

07:18.170 --> 07:18.950
from.

07:18.950 --> 07:23.480
Next, we've taken a closer look at vagrant file.

07:23.480 --> 07:26.900
We've removed four lines of this file.

07:26.900 --> 07:29.000
Now, a small task for you.

07:29.030 --> 07:38.090
First, you have to create a new folder for a new vagrant project, and in this folder type, the command,

07:38.090 --> 07:46.880
which will create a new vagrant file containing the information about Santos seven box.

07:46.880 --> 07:50.750
You don't have to specify the address for this box.

07:50.750 --> 07:52.640
Just the box itself.

07:52.640 --> 08:00.230
Please press pause here, and in a few seconds I'll show the answer for this simple task.

08:00.230 --> 08:05.000
So the commands you had to use are as follows.

08:05.000 --> 08:10.010
McDeere and the name of your work and folder, for example.

08:10.010 --> 08:18.200
Santos, seven Seed Center, seven, and Vagrant Center slash seven.

08:18.200 --> 08:24.350
The name for this box could be found on EBS dot Vagrant app dot com.
