Create CentOS on OpenNebula | Ubuntu | Debian VM template

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatshut down

How to create VM templates for Ubuntu/CentOS/Debian and any other Linux distributions in OpenNebula? In OpenNebula, if there is no defined VM template, you cannot create a virtual machine. The VM template pool allows OpenNebula administrators and users to register virtual machine definitions in the system and then instantiate them as virtual machine instances.

The VM template can be instantiated multiple times and can also be shared with other users in the OpenNebula cloud platform. Templates are stored in the system, and VMs can be easily browsed and instantiated from them. We will show an example of defining a VM template on OpenNebula, and the same process can be applied to any other template.

Before proceeding, OpenNebula requires an operating system image. For how to do this, please refer to the following guide:

Import CentOS Qcow2 images on OpenNebula

Create a VM template on OpenNebula

The virtual machine created on the OpenNebula system will include:

  • Capacity in terms of memory and CPU
  • A group of NICs connected to one or more virtual networks
  • A set of disk images
  • Optional attributes, such as VNC graphics, startup sequence, context information, etc.

Step 1: Start VM template creation

Log in to the OpenNebula Sunstone web console and navigate to “Template“>”virtual machine

hit”+“Button and select “Create”

Step 2: Fill in the information required to create the template

under”General“Partial input:

  • Template name
  • Template description
  • Choose a hypervisor
  • Template logo
  • Memory and CPU details

Create VM template OpenNebula 2

under”Store“Partial input:

  • Select the VM image added before

Create VM template OpenNebula 03

under”The internet“Partial input:

  • Default network of the VM template
  • Any other network options applicable to the template

Create VM template OpenNebula 04

under”Operating system and CPU“Set the options you want to use.

  • Boot up
  • core
  • Blue plate
  • feature
  • CPU model

I added two options below that disable IPv6 and change the naming of the network interface:

 net.ifnames=0 ipv6.disable=1

See the screenshot below.Create VM template OpenNebula 05

Under “Input/Output”, you can set graphics and PCI optionsCreate VM template OpenNebula 06

allowable”Context“>”Configuration“Part. The script text to be executed when the machine starts is the same.Create VM template OpenNebula 07

You can go to “schedule” with”Hybrids“Section. Click”create“Button.

The template should appear in the list of available OpenNebula VM templates.Create VM template OpenNebula 09

Clicking on the name will display more information about the template:Create VM template OpenNebula 10

Step 3: Test by creating a VM from a template

We can test our template by provisioning VM instances from it. This is through “Number of instances“>”virtual machine“>”+ >”createCreate VM template OpenNebula 11

Select the VM template from which you want to create the VM.Create VM template OpenNebula 13

Name the virtual machine, create the number of instances, and customize resource allocation as needed.Create VM template OpenNebula 12

And all other parameters you want to set.Create VM template OpenNebula 14

After selecting “Create”, the virtual machine will be in the “Suspended” state.Create VM template OpenNebula 15

Once it is ready for use, it will be in a “running” state.Create VM template OpenNebula 16

You can get the VM details, such as IP address, by clicking on the instance name.Create a VM template OpenNebula 17

Test connectivity by pinging the IP address:

$ ping -c 1
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.611 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.611/0.611/0.611/0.000 ms

Do the same for SSH

$ ssh  [email protected]
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:/k4pJX5pZiQHPMgnkPLAjtwqbBmNbuY6QP+5BiTEmHA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/josphat/.ssh/id_rsa':
Activate the web console with: systemctl enable --now cockpit.socket

[[email protected] ~]$

Confirm that the interface naming has been changed to be configured through kernel parameters:

$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:00:ac:14:14:64 brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::acff:fe14:1464/64 scope link
       valid_lft forever preferred_lft forever

We have confirmed that the VM was successfully created from the template. We can also use ssh to enter the instance.


Other guides about OpenNebula:

How to configure NFS file system as OpenNebula data storage

You can download this article in PDF format via the link below to support us.
Download the guide in PDF formatshut down

Related Posts