Using cloud-init in oVirt

 What is cloud-init?

cloud-init provides the capability of early initialization of a virtual machine.
This usually happens during the startup of the guest operating system on the virtual machine.

 What can I do with it in oVirt?

 oVirt allows you to configure:

Additionally it allows you to pass a custom cloud-init script, which should give you the full flexibility cloud-init provides.

 Virtual machine requirements

In order to use cloud-init with a virtual machine the cloud-init package has to be installed on the VM in question. For most distributions packages for cloud-init should be available in their respective package repositories.

So the VM, you would like to use cloud-init with, needs to have preinstalled the cloud-init package and should be configured to start automatically on boot.

 cloud-init configuration within oVirt

There are two ways to configure the cloud-init parameters:

 How to permanently setup cloud-init parameters for a VM in oVirt

  1. Log in to the user portal or the administration portal of your oVirt instance
  2. In case of the user portal, click on the ‘Extended’ link in the left upper corner to get the list of your VMs. (This step is not required for the Administration portal)
  3. Select the VM you’d like to configure in the list by left clicking it
  4. The ‘Edit’ link in the list header should now become active – Click it
  5. The ‘Edit Virtual Machine’ dialog opens up.
  6. Now choose the ‘Initial Run’ section on the left hand side of the dialog (Usually the 3rd entry from the top) If the ‘Initial Run’ section is not present, press the ‘Show Advanced Options’ in the left bottom area of the dialog, to reveal hidden options.
  7. You’re presented with a check box ‘Use Cloud-Init/Sysprep’ – mark it as checked – This will reveal the available options.

Now you can configure the options as you wish and after pressing OK, with the next start of the VM the configuration should be applied automatically.

 How to temporarily setup cloud-init parameters for a VM in oVirt via Run-Once

  1. Log in to the user portal or the administration portal of your oVirt instance
  2. In case of the user portal click on the ‘Extended’ link, in the left upper corner to get the list of your VMs. (This step is not required for the Administration portal)
  3. Select the VM you’d like to configure in the list by left clicking it
  4. Click the ‘Run-Once’ link in the list header – This will open the ‘Run Virtual Machine(s) dialog
  5. Now choose the 'Initial Run’ section
  6. You’re presented with a check box ‘Use Cloud-Init’ – mark it as checked – This will reveal the available options.

Now you can configure the options as you wish and after pressing OK the VM will be started with these options configured and being applied to the within the VM.
The information entered will not be persisted and is discarded on shutdown of the VM, applied changes inside of the VM of course stay as they are, as long as it is not a stateless VM.

 Using the cloud-init with the oVirt SDK

One can also utilize cloud-init with the oVirt SDK
An example for this can be found here

 Screenshots

Here are now some screenshots from the Run Once dialog
The configuration, looks and behavior in the Edit VM dialog are equivalent.

 Run Once Dialog – Unchecked cloud-init checkbox

Run Once Dialog -- unchecked cloud-init checkbox

 Run Once Dialog – Checked cloud-init checkbox default

Run Once Dialog -- Checked cloud-init checkbox default

 Run Once Dialog – Hostname, timezone and authentication information

Run Once Dialog -- Hostname, timezone and authentication information

 Run Once Dialog – Network configuration DHCP

Run Once Dialog -- Network configuration DHCP

 Run Once Dialog – Network configuration static

Run Once Dialog -- Network configuration static

 Run Once Dialog – Custom cloud-init script

Run Once Dialog -- Custom cloud-init script

 A video presentation

This is an old presentation from 2013 made by my colleague Omer Frenkel
It’s not completely up to date but at least gives an idea :-)

 
6
Kudos
 
6
Kudos

Now read this

Meet pypa, libpypa

For quite a while, I have been playing with the thought of writing a parser for a programming language. I have never written one before and therefore I somehow had to scratch an itch in that regards. That itch however was never that much... Continue →