You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

How can I create Ubuntu / CentOS / Debian and any other Linux distribution VM Template in OpenNebula?. In OpenNebula, Virtual Machines cannot be created without defined VM Templates. The VM Template Pool allows OpenNebula administrators and users to register Virtual Machine definitions in the system, to be instantiated later as Virtual Machine instances.

The VM Templates can be instantiated several times, and also shared with other users in OpenNebula cloud platform. The Templates are stored in the system and they’re easy to browse and instantiate VMs from them. We will show one example of defining VM templates on OpenNebula and the same process can be applied for any other template.

Before you proceed, an OS image is required in OpenNebula, refer to guide below for how-to:

Import CentOS Qcow2 Images on OpenNebula

Creating a VM Template on OpenNebula

A Virtual Machine created on OpenNebula system will consist of:

  • A capacity in terms of memory and CPU
  • A set of NICs attached to one or more virtual networks
  • A set of disk images
  • Optional attributes like VNC graphics, the booting order, context information, etc.

Step 1: Initiate VM Template Creation

Login to OpenNebula Sunstone Web console and navigate to “Templates” > “VMs

Create VM Template OpenNebula 01

Hit the “+” button and choose “Create

Step 2: Fill the required information for Template creation

Under the “General” section input:

  • Template Name
  • Template Description
  • Choose Hypervisor
  • Template Logo
  • Memory and CPU details
Create VM Template OpenNebula 2

Under the “Storage” section input:

  • Choose VM image added previously
Create VM Template OpenNebula 03

Under the “Network” section input:

  • Default network for the VM template
  • Any other network option that applies for your template
Create VM Template OpenNebula 04

Under “OS & CPU” set options you want to use.

  • Boot
  • Kernel
  • Ramdisk
  • Features
  • CPU Model

I’ve added below two options which disables IPv6 and change naming of network interfaces:

 net.ifnames=0 ipv6.disable=1

See below screenshot.

Create VM Template OpenNebula 05

Under “Input/Output” you can set Graphics and PCI options

Create VM Template OpenNebula 06

A default SSH key can be added under “Context” > “Configuration” section. Same for text of script to be executed when the machine starts up.

Create VM Template OpenNebula 07

You can play with other settings in the “Scheduling” and “Hybrid” sections. When done hit the “Create” button.

The template should appear in the list of available OpenNebula VM Templates.

Create VM Template OpenNebula 09

Clicking on the name displays more information about the template:

Create VM Template OpenNebula 10

Step 3: Test by Creating VM from the Template

We can test our template by provisioning a VM instance from it. This is done from “Instances” > “VMs” > “+ > “Create

Create VM Template OpenNebula 11

Choose VM template to create a VM from.

Create VM Template OpenNebula 13

Give the VM a name, instance count to create, and customize resources allocation if need be.

Create VM Template OpenNebula 12

And all other parameters that you want to set.

Create VM Template OpenNebula 14

Once you choose “Create” the VM will be in Pending state.

Create VM Template OpenNebula 15

Once ready for use it will be in “RUNNING” state.

Create VM Template OpenNebula 16

You can get VM details such as IP Address by clicking the instance name.

Create VM Template OpenNebula 17

Test connectivity by pinging the IP Address:

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

--- 172.20.20.100 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 '172.20.20.100 (172.20.20.100)' 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 '172.20.20.100' (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 interface naming changed as 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 127.0.0.1/8 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 172.20.20.100/24 brd 172.20.20.255 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’ve confirmed the VM was created successfully from the template. We were also able to ssh into the instance.

References:

Other guides on OpenNebula:

How To Configure NFS Filesystem as OpenNebula Datastores

As an appreciation for the content we put out,
we would be thrilled if you support us!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here