- In this video, I'm going to show you how to use
cloud-init to customize images.
Cloud-init itself, is an infrastructure as code solution,
and it allows the user to easily deploy virtual machines
on supported platforms.
And these supported platforms include:
KVM, OpenStack, AWS,
Microsoft Azure, just to mention a couple of them.
And there's more.
Do notice, that due to a bug cloud-init currently,
does not work in VMware workstation or Fusion.
I can show you what to do,
but you might be in a situation, where it doesn't work.
So how do you use cloud-init?
Well, to deploy a virtual machine with cloud-init,
you'll need to create a YAML file,
containing installation instructions.
And a (simple) example, YAML is provided
as user-data.yaml in the course git repository.
You can find it at github.com/sandervanvugt/lfcs,
and use this YAML, in a virt-install command for a fully
automated installation of a virtual machine in KVM.
Let me demonstrate how that works.
For your convenience here are the steps in the demo.
So first, we need to clone the git course repository.
Oh, it's already there.
Well, that makes it even easier.
So in this git course repository
we have this user-data.YAML.
In the user-data .YAML is a very simple YAML
that is providing the cloud in its configuration.
So, we have a default_username admin
and this default_user needs to be a member
of the group wheel.
Now, in order to do this, next we need a qcow2 image,
for a virtual machine that we are going to install in KVM.
So next, we need W gits to, actually get a qcow2 image
that we are going to use, with cloud in it.
All right, so in the previous video,
you have seen how we can create a virtual machine,
using Virt-Manager.
Here, we do everything command line, using Virt-install.
Now, Virt-install needs a couple of arguments.
The name of the machine, you want to create the amount
of memory, which by default is expressed in megabytes.
The VCPUs, whether or not you want to attach
a graphical console, always variant detect is on,
which will automatically find the operating system,
the disc that you are going to create.
So in this case it will be a file with the name
fedora01.qcow, and the size of the disk,
which is expressing in gigabytes.
Then we need to specify the console,
the console type,
which is virtio,
the serial port N, and last but not least, is cloud-init,
use data, it's user data.yaml.
Now the essence of this command,
is that you can do a fully, unattended installation.
So once you hit enter, the installation
of the virtual machine will start, fully unattended.
And if all goes well, at the end,
you have a working virtual machine.