So, yes,
a big warm welcome to our first demonstration, and remember,
it's the hands‑on experience that is really going to ensure you
properly understand the objectives.
So here we're looking at deploying our lab systems. We're going
to be demonstrating on Ubuntu 20.04 how we can install Vagrant,
VirtualBox, and Git. It is mainly Ubuntu that we're going to be
using within this course,
so that's the main virtual machine that we'll be using; however,
having the separate virtual machines for AlmaLinux and openSUSE allows
us to look more at how our configuration management systems work, and
work effectively across distributions.
If you're using a different virtualization system, then that's fine.
Also, you could be using hardware, so it doesn't really matter, but you
just have to make sure you've got machines to work with.
Additionally,
of course, if you've already got Vagrant installed, then
there's no need to install Vagrant again, but of course you
can make use of our Vagrantfile.
Come on,
let's find that command line. And here we are then on my Ubuntu host
machine. I'm going to use this machine to demonstrate the installation of
Vagrant and VirtualBox, but additionally we can put on Git and we'll be
putting on my favorite text editor Vim. But, obviously, you don't have to
take my favoritism into consideration, use whichever text editor you
would like to use.
So anyway,
beginning our journey, we know within an Ubuntu system we need to update
our package cache before we do any installations. So we can elevate our
privileges with sudo and then it's the good old apt update. Now here you
can see I have to authenticate through to the sudo system, but also, so
long as I'm running my administrative commands that need elevation
within a 5‑minute period of the last command, it will cache my
credentials.
So having now updated the metadata,
I can go straight ahead and run the installation and, of
course, sudo isn't going to require the password. So we're
going to use sudo and apt install.
We're going to be adding in the ‑y so we don't need to worry
about accepting the prompt message, and we'll be installing then
our vagrant virtual machine manager along with our hypervisor
virtualbox, git, and vim.
Now this will take a little while to run through, so I've
cut a little bit of it out, but allow 3 or 4 minutes for
the installation to go ahead.
But now, of course, having installed it, we can go through and check the
version of products that we've installed. Firstly, I can go through and
check the version of Vagrant, so vagrant and version, and we can see this
is 2.2.6. Now with VirtualBox I don't so much have a version command, but
I am able to use the virtualbox command and then ‑‑help, and we can see
then this is version 6.1.32. So it's good we've got the elements that we
need.
We're now going to clone the repository that I'm using for this course.
This will have files that will help you for
demonstrations throughout the course.
If we go through to github.com running our git clone,
through to my personal repository,
theurbanpenguin, and then the repository name that we need to
look at is comptia and automation, ‑automation.
That will then create the comptia‑automation directory for us in
the directory that you downloaded it to or cloned it to, so I can
move into that so we can see how we can create a consistent build
of virtual machines.
So moving into the automation and vagrant directory, I've got a Vagrantfile.
If I look at this file, this file defines our virtual machines.
We've got three virtual machines defined, alma, opensuse, and ubuntu. It's
Ubuntu that we use mainly, and I've also set a little bit more memory for
this, but if you don't have so much memory available, you can reduce it to
maybe a little bit less, but it's going to be our main virtual machine that
we're going to be using. To bring this virtual machine up, we issue the
command vagrant up. The first thing it's going to do is check for a local
version of the Ubuntu box that we're going to clone. That's not going to be
there, so we're going to download the box, and then we're going to clone the
box image to a new virtual machine and bring that up.
So, again, it's going to take a little bit of time.
Much of this time is going to be dependent on the speed of your
network, but these box files tend to be quite well built, so
they're not particularly huge coming down. As we then go through
the boot process, again,
I'm just cutting a little bit of time out, but maybe the first boot
might take 5 minutes or so, depending on the speed of your network and
your hardware. But once it has then booted, it's a very quick way to
be able to get our operating systems up and running, and in a
consistent way; really important both for our labs, but also in a
DevOps environment.
If I now go through and do a vagrant ssh to the ubuntu system, we can see
then that our hostname has changed from ubuntu20 just to ubuntu, and our
user account now is the vagrant user account.
This has full administrative privileges on the system. But for the
moment we don't really need to do anything on this system, so
allow me the pleasure of exiting out of our virtual machine. To
manage our virtual machines,
I can look at vagrant and status. Again it will make reference to our
Vagrantfile, and we can see then that we've got the three virtual
machines that have been defined, alma, opensuse, and ubuntu, and
ubuntu, of course, is running at the moment, but we haven't created
the alma or opensuse box yet.
If I want to bring the ubuntu box down,
then I can do a vagrant halt on ubuntu, and it will power the system down.
So we can see the message, and it's just then bringing our virtual machine
down, and I've got this very simplified way of managing my virtual machines from a command line interface.