1 00:00:06,780 --> 00:00:08,760 - In this video, I'm going to show you how to use 2 00:00:08,760 --> 00:00:11,670 cloud-init to customize images. 3 00:00:11,670 --> 00:00:15,300 Cloud-init itself, is an infrastructure as code solution, 4 00:00:15,300 --> 00:00:18,210 and it allows the user to easily deploy virtual machines 5 00:00:18,210 --> 00:00:20,430 on supported platforms. 6 00:00:20,430 --> 00:00:22,113 And these supported platforms include: 7 00:00:22,113 --> 00:00:25,290 KVM, OpenStack, AWS, 8 00:00:25,290 --> 00:00:29,010 Microsoft Azure, just to mention a couple of them. 9 00:00:29,010 --> 00:00:29,860 And there's more. 10 00:00:30,930 --> 00:00:33,660 Do notice, that due to a bug cloud-init currently, 11 00:00:33,660 --> 00:00:36,174 does not work in VMware workstation or Fusion. 12 00:00:36,174 --> 00:00:38,010 I can show you what to do, 13 00:00:38,010 --> 00:00:41,490 but you might be in a situation, where it doesn't work. 14 00:00:41,490 --> 00:00:43,053 So how do you use cloud-init? 15 00:00:44,400 --> 00:00:47,010 Well, to deploy a virtual machine with cloud-init, 16 00:00:47,010 --> 00:00:48,480 you'll need to create a YAML file, 17 00:00:48,480 --> 00:00:51,300 containing installation instructions. 18 00:00:51,300 --> 00:00:53,700 And a (simple) example, YAML is provided 19 00:00:53,700 --> 00:00:56,760 as user-data.yaml in the course git repository. 20 00:00:56,760 --> 00:01:00,933 You can find it at github.com/sandervanvugt/lfcs, 21 00:01:02,010 --> 00:01:04,860 and use this YAML, in a virt-install command for a fully 22 00:01:04,860 --> 00:01:08,043 automated installation of a virtual machine in KVM. 23 00:01:10,320 --> 00:01:12,120 Let me demonstrate how that works. 24 00:01:12,120 --> 00:01:14,823 For your convenience here are the steps in the demo. 25 00:01:19,470 --> 00:01:22,383 So first, we need to clone the git course repository. 26 00:01:23,310 --> 00:01:24,600 Oh, it's already there. 27 00:01:24,600 --> 00:01:26,253 Well, that makes it even easier. 28 00:01:29,880 --> 00:01:31,950 So in this git course repository 29 00:01:31,950 --> 00:01:33,783 we have this user-data.YAML. 30 00:01:36,827 --> 00:01:39,660 In the user-data .YAML is a very simple YAML 31 00:01:39,660 --> 00:01:42,810 that is providing the cloud in its configuration. 32 00:01:42,810 --> 00:01:45,630 So, we have a default_username admin 33 00:01:45,630 --> 00:01:47,610 and this default_user needs to be a member 34 00:01:47,610 --> 00:01:49,500 of the group wheel. 35 00:01:49,500 --> 00:01:54,199 Now, in order to do this, next we need a qcow2 image, 36 00:01:54,199 --> 00:01:57,963 for a virtual machine that we are going to install in KVM. 37 00:01:59,280 --> 00:02:03,510 So next, we need W gits to, actually get a qcow2 image 38 00:02:03,510 --> 00:02:05,973 that we are going to use, with cloud in it. 39 00:02:08,370 --> 00:02:09,900 All right, so in the previous video, 40 00:02:09,900 --> 00:02:12,240 you have seen how we can create a virtual machine, 41 00:02:12,240 --> 00:02:14,220 using Virt-Manager. 42 00:02:14,220 --> 00:02:17,400 Here, we do everything command line, using Virt-install. 43 00:02:17,400 --> 00:02:19,890 Now, Virt-install needs a couple of arguments. 44 00:02:19,890 --> 00:02:22,500 The name of the machine, you want to create the amount 45 00:02:22,500 --> 00:02:25,830 of memory, which by default is expressed in megabytes. 46 00:02:25,830 --> 00:02:28,530 The VCPUs, whether or not you want to attach 47 00:02:28,530 --> 00:02:31,830 a graphical console, always variant detect is on, 48 00:02:31,830 --> 00:02:34,380 which will automatically find the operating system, 49 00:02:35,670 --> 00:02:37,350 the disc that you are going to create. 50 00:02:37,350 --> 00:02:39,480 So in this case it will be a file with the name 51 00:02:39,480 --> 00:02:43,650 fedora01.qcow, and the size of the disk, 52 00:02:43,650 --> 00:02:46,023 which is expressing in gigabytes. 53 00:02:47,490 --> 00:02:50,370 Then we need to specify the console, 54 00:02:50,370 --> 00:02:51,393 the console type, 55 00:02:52,260 --> 00:02:53,820 which is virtio, 56 00:02:53,820 --> 00:02:57,870 the serial port N, and last but not least, is cloud-init, 57 00:02:57,870 --> 00:03:01,710 use data, it's user data.yaml. 58 00:03:01,710 --> 00:03:02,707 Now the essence of this command, 59 00:03:02,707 --> 00:03:07,050 is that you can do a fully, unattended installation. 60 00:03:07,050 --> 00:03:08,880 So once you hit enter, the installation 61 00:03:08,880 --> 00:03:12,030 of the virtual machine will start, fully unattended. 62 00:03:12,030 --> 00:03:13,800 And if all goes well, at the end, 63 00:03:13,800 --> 00:03:15,550 you have a working virtual machine.