WEBVTT

00:06.330 --> 00:13.500
Now let's take a look at hands on demonstration and how we can set up and start our virtual machines

00:13.500 --> 00:18.570
and verify once they are started up that we've got connectivity.

00:18.600 --> 00:25.770
Now we are going to set up our virtual machine so we can run Vagrant and Virtual Box on pretty much

00:25.770 --> 00:30.750
any of our operating systems on Windows, macOS and Linux.

00:31.230 --> 00:36.210
As you remember, it's free and there is no charge for Vagrant or Virtual box.

00:36.210 --> 00:39.750
So so ensure that you have those installed.

00:39.750 --> 00:44.770
Once you've got them installed, then create yourselves a working directory.

00:44.790 --> 00:52.530
I've just set up, I've just created a top level called Vagrant in my home directory and a sub directory.

00:52.530 --> 01:00.480
So they are really work as project directories so we can create the virtual machine configuration files

01:00.480 --> 01:02.760
within our project directory.

01:02.940 --> 01:10.500
We've got a vagrant file, so if you go through and just list out the contents of this, we've got a

01:10.500 --> 01:16.830
vagrant file and we've got an Ansible playbook to help configure these systems.

01:16.830 --> 01:22.790
Both the playbook and the vagrant needs to be in your working directory.

01:22.800 --> 01:31.900
And of course you can use Git clone to just grab this directory and run vagrant from here.

01:31.920 --> 01:38.820
The address for this repository is GitHub.com, the Labs eight Vagrant.

01:38.850 --> 01:43.970
We'll take a look at their contents, but we can clone their contents.

01:43.980 --> 01:47.490
Let's just move out to to my home directory.

01:47.490 --> 01:50.040
So just city on its own.

01:50.040 --> 01:58.680
I run a get clone and then http as going through the github.com and looking at my repository.

01:58.680 --> 01:59.250
So.

01:59.250 --> 02:08.190
So this particular directory got a copy of vagrant file and the ubuntu dot yaml file for you to use

02:08.190 --> 02:13.020
so you don't have to worry about creating them by yourself.

02:13.290 --> 02:20.370
When I take a look inside of the vagrant file, the main configuration that we are looking at is then

02:20.370 --> 02:29.070
a configuration block that is shared for all of our virtual machines and we are using the Ubuntu slash

02:29.070 --> 02:31.590
focal 64 image.

02:31.590 --> 02:39.060
We're going to provision both so that we can install extra configuration options using ansible.

02:39.060 --> 02:46.020
So ansible will be installed on our local systems and our virtual machine guests and we'll run them

02:46.020 --> 02:49.530
the ubuntu dot yaml playbook.

02:49.560 --> 02:55.410
Each of the systems has been assigned to gigs of RAM and two virtual CPUs.

02:55.410 --> 03:03.360
As we then take a look at ubuntu one where set in the hostname and the IP address of that and then the

03:03.360 --> 03:10.890
specific configuration block for ubuntu to where we are setting up its host name to be ubuntu two and

03:10.890 --> 03:14.700
the 1922 address the playbook itself.

03:14.700 --> 03:22.740
If I go through and look at the ubuntu dot yaml file, so the ansible is going to do some further configuration

03:22.740 --> 03:31.470
making sure that where we update our package cache and upgrade any software that needs upgrading.

03:31.500 --> 03:39.210
We are added in the ubuntu ssh server configuration file just to make sure that we can use password

03:39.210 --> 03:41.790
based authentication by default.

03:41.790 --> 03:48.750
It is disabled in this VMs and then we'll restart the SSH server.

03:48.780 --> 03:56.220
Now it's easier doing this through Ansible so we don't have to get into the detail too much of what

03:56.220 --> 03:57.420
we're looking at.

03:57.450 --> 04:01.980
We'll learn more about this as we go through any vagrant commands.

04:01.980 --> 04:10.470
Them that are issued from this directory are going to work with our vagrant file so I can run them my

04:10.470 --> 04:19.110
vagrant command and do a box update, which is just going to make sure that we've got the up to date

04:19.110 --> 04:21.600
version of the virtual machine images.

04:21.600 --> 04:24.680
I can then go through and do a vagrant up.

04:24.690 --> 04:32.220
If I don't specify the machine name, it's going to bring all of the machines up or both of them.

04:32.220 --> 04:38.910
In this case, if there were more virtual machines, for example, five virtual machines, it would

04:38.910 --> 04:43.590
bring up five virtual machines with this vagrant up command.

04:43.590 --> 04:52.710
And if you want to bring up only one virtual machine, you run vagrant up Ubuntu one for example, or

04:52.710 --> 04:53.730
Ubuntu two.

04:53.730 --> 04:58.790
So let's move this on the top of the screen by enter and control.

04:59.100 --> 05:05.790
Just move you to the top of the screen and clear the screens, contents and.

05:06.150 --> 05:10.640
We can then go through and run our Vagrant app command.

05:10.650 --> 05:18.990
It's going to start our virtual machine, so it will clone the virtual box image and then start both

05:18.990 --> 05:25.890
of our virtual machines and then run the previous scripts, which we are running through Ansible.

05:25.920 --> 05:30.400
You can leave this running for a little while and then come back as we come back.

05:30.420 --> 05:38.190
We're able to see the results of what's been happening so we can see the finished configuration, the

05:38.190 --> 05:44.310
Ubuntu to system and previously we would have configure the Ubuntu one virtual machine guest.

05:44.340 --> 05:50.280
So we are up and running, but let's go through and begin by cleaning our screen.

05:50.280 --> 05:56.940
And then the convenient thing that we have with vagrant is then I can just go.

05:56.950 --> 05:57.840
Vagrant.

05:57.990 --> 05:58.930
Ssh.

05:58.950 --> 06:06.420
I don't need to really worry about the system that I'm connected to its IP address.

06:06.420 --> 06:14.790
I don't have to worry about passwords as key based authentication has already been set up, but I do

06:14.790 --> 06:18.110
need to specify to which system I want to connect.

06:18.120 --> 06:20.310
For example, Ubuntu one.

06:20.310 --> 06:27.600
So that then gets us into the system and we are now up and running on Linux.

06:27.600 --> 06:35.130
So everything then is going to be a load helper and you guys are going to be much more happy looking

06:35.130 --> 06:39.000
at Linux than my standard macOS desktop.

06:39.000 --> 06:40.720
So here we are.

06:40.740 --> 06:45.410
Anyway, let's take a look that the configuration worked for us.

06:45.420 --> 06:53.970
If I go through and run and P and proc command, it just becomes a very simple way for the number of

06:53.970 --> 06:54.870
processors.

06:54.870 --> 06:57.270
So I've got two processors.

06:57.270 --> 06:59.570
There is what we had configured.

06:59.580 --> 07:06.870
If I want to check the amount of memory that we've got, I can use three and then this age to display

07:06.870 --> 07:08.910
it in a human readable format.

07:08.910 --> 07:18.630
And we can see that when we set to gigabyte, that gives me roughly 1.9 gigabytes available within our

07:18.630 --> 07:19.770
virtual machine.

07:19.770 --> 07:27.690
So this is the global configuration that was set in our vagrant file, and we can see that it's working

07:27.690 --> 07:28.680
well for us.

07:28.680 --> 07:32.670
When I look at the IP address that I have.

07:32.670 --> 07:45.000
So IP dash four address so we can see them that I've got the 1922.168. 56.101 address.

07:45.000 --> 07:56.520
We can also see that I should be able to pin the remote system so pin 19221.168. 56.102.

07:56.520 --> 08:01.680
And that will that will be the Ubuntu two system that I'm connecting to.

08:01.680 --> 08:05.760
If I don't specify the number of pins to send, it just continues.

08:05.760 --> 08:13.650
But I can use control plus C to stop those pins being sent once I'm happy I've got communication.

08:13.650 --> 08:22.500
If I then go through and use exit, I leave the system and I return back to the MAC system and we're

08:22.500 --> 08:30.750
back then in the Mac OS and I no longer Linux, but at least we've learned how we can get our system

08:30.750 --> 08:31.730
up and running.

08:31.740 --> 08:39.900
I can also use the Vagrant and Status Command to take a look at what's happening with our virtual machines

08:39.900 --> 08:47.670
and we can use that and we can see that they are both running and I can keep them running, but if I

08:47.670 --> 08:52.830
no longer need them, I can use Vagrant hold to power them off.

08:52.830 --> 08:57.780
If I need to start all over again, I can use vagrant up.

08:57.780 --> 09:03.080
I can use a vagrant destroy to destroy and delete those virtual machines.

09:03.090 --> 09:09.270
Now, for the moment I'm going to keep my virtual machines running because we are not really finished

09:09.270 --> 09:10.550
with them at the moment.

09:10.560 --> 09:18.660
Now, if besides this configuration, you need to run some script on this, on the on these both virtual

09:18.660 --> 09:27.930
machines or on one of these virtual machines, you can use VM dot provision configuration and you need

09:27.930 --> 09:31.830
to specify the path to the provisioning script.

09:32.040 --> 09:39.240
Also, if you need to forward some port, for example, if you install like let me show you this Jenkins

09:39.240 --> 09:47.910
configuration file, I'll seed into the parent folder and then seed into the Jenkins folder.

09:47.910 --> 09:50.040
I'll open up this vagrant file.

09:50.040 --> 09:57.600
And as you can see, we've got provision here, the provisioning script path, and we can also forward

09:57.600 --> 10:05.280
port from our vagrant virtual machine to our host machine so we can access this.

10:05.830 --> 10:08.380
Box and our host Virtual Machine.

10:08.380 --> 10:16.710
For example, if we run this virtual machine, we can access this host by typing local host column 88

10:16.810 --> 10:23.710
on our host machine, and we'll get this Jenkins instance as a lab environment.

10:23.740 --> 10:27.550
Now, let me run this virtual environment as well.

10:27.580 --> 10:30.100
I'll type vagrant up.

10:30.100 --> 10:38.590
Jenkins first, make sure that I'm in a Jenkins directory and I'll pause here and wait until this virtual

10:38.590 --> 10:39.970
machine is up and running.

10:39.970 --> 10:43.980
And when it's up and running, I can run the following command.

10:43.990 --> 10:46.650
Vagrant Global status.

10:46.660 --> 10:53.230
And as you can see, we've got three virtual machines up and running, namely Ubuntu one, Ubuntu two

10:53.230 --> 10:55.650
and Jenkins virtual machine.

10:55.660 --> 11:05.620
And now if you want to halt or destroy or start some virtual machine outside of our virtual environment

11:05.770 --> 11:08.140
of our work and folder.

11:08.140 --> 11:17.410
So to say project folder, we can go ahead and run vagrant, destroy and use the virtual machines ID

11:17.410 --> 11:28.390
number so I can select it, press command C and insert it in my vagrant command, namely vagrant destroy

11:28.990 --> 11:30.640
followed by the ID.

11:31.180 --> 11:33.700
Sometimes you can get some screen shares.

11:33.700 --> 11:40.480
That vagrant is being taken by another process and you can not perform this action.

11:40.480 --> 11:44.350
In this case, you could just kill the process of Vagrant.

11:44.350 --> 11:53.980
But first you type piece pipe vagrant and then you type kill Dash nine and the process ID it will kill

11:53.980 --> 11:57.190
the vagrant process and you can run it again.
