WEBVTT

00:06.380 --> 00:13.730
In order to use multiple virtual machines within our project, we need to tell Vagrant about them,

00:13.730 --> 00:21.320
and we need to provide additional configuration for the individual virtual machines within the ordinary

00:21.320 --> 00:24.040
Vagrant project configuration file.

00:24.050 --> 00:32.150
We can tell Vagrant that we want to assign a name to a virtual machine being managed by the project.

00:32.150 --> 00:40.520
Within this sub configuration, we provide the information Vagrant needs that is specific to that VM.

00:40.520 --> 00:48.950
The syntax for the sub configurations is as follows You have to provide the name of the virtual machine

00:48.950 --> 00:51.670
after config, dot vm dot.

00:51.680 --> 00:54.860
Define configuration information.

00:54.860 --> 00:58.640
So the whole line will look like config, dot vm dot.

00:58.640 --> 01:06.890
Define name of the virtual machine do and the name of the virtual machine again followed by the end

01:06.890 --> 01:07.610
command.

01:07.610 --> 01:17.630
For example, the file the vagrant file for two virtual machines will look like this vagrant API version

01:17.630 --> 01:27.380
two and the configuration for it where green dot configure two and double quotes and break it do config

01:27.380 --> 01:35.270
and then followed by the lines describing the machines we want to run.

01:35.270 --> 01:41.870
In this case it will be server one or SRB one and server two for each server.

01:41.870 --> 01:55.130
We define the box by the LAN server as a 1.3. box equals to hashicorp slash size 64 or centos slash

01:55.130 --> 01:55.700
seven.

01:55.700 --> 02:04.340
As in my case, each configuration sub configuration for the VM is closed by the end command and the

02:04.340 --> 02:07.400
end command for the whole vagrant file.

02:07.400 --> 02:12.680
So in this case we will initiate two virtual machines as we want.

02:12.700 --> 02:22.550
Enter server two running CentOS slash seven box when our multiple machines boot up in our multi machine

02:22.550 --> 02:32.090
project, Vagrant automatically maps different ports from our host machine to the SSH ports on the various

02:32.090 --> 02:33.260
guest machines.

02:33.260 --> 02:40.280
Let's take a look at the console output when booting a vagrant project with two virtual machines and

02:40.280 --> 02:46.730
find the information regarding a SSH port assigned to each of these machines.

02:46.730 --> 02:55.010
As you can see, vagrant maps the ssh port on the virtual machine designated as we want to port with

02:55.010 --> 03:03.590
the following number 2222 on the host machine and the SSH port of the machine designated as with two

03:03.590 --> 03:06.590
to the port, which is available now.

03:06.590 --> 03:15.080
This gives us the opportunity to simply using the standard SSH command from a terminal like party on

03:15.080 --> 03:23.690
Windows machine or Siguiente terminal like mine to connect to local host with a port number that vagrant

03:23.690 --> 03:25.460
assigns to each machine.

03:25.460 --> 03:32.120
For example, to connect to the machine that is mapped to port 20 200.

03:32.120 --> 03:40.640
We simply run the switch followed by the user vagrant in this case, which is default for all vagrant

03:40.640 --> 03:46.730
machines at local host dash P and port number.

03:46.730 --> 03:55.610
This this P port number option tells the command to use a non standard port and specifies the port we

03:55.610 --> 03:56.720
wish to use.

03:56.720 --> 03:58.600
It could be any number.

03:58.610 --> 04:06.530
Alternatively, we can use the vagrant ssh command to connect to the virtual machines.

04:06.530 --> 04:13.850
The difference is that in a multi virtual machine environment we must also provide the name of the virtual

04:13.850 --> 04:14.540
machine.

04:14.540 --> 04:18.920
For example, Vagrant is a such as av1.

04:18.920 --> 04:25.820
This is the most common usage of connecting to machine rather than directly connecting to the virtual

04:25.820 --> 04:28.100
machine via its IP address.
