Create CentOS|Ubuntu|Debian VM Templates on OpenNebula

Posted on 323 views

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:

Create CentOS|Ubuntu|Debian VM Templates 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


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


Under the “Storage” section input:

  • Choose VM image added previously


Under the “Network” section input:

  • Default network for the VM template
  • Any other network option that applies for your template


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.


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


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


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.


Clicking on the name displays more information about the template:


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


Choose VM template to create a VM from.


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


And all other parameters that you want to set.


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


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


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


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 interface naming changed as configured through kernel parameters:

$ ip ad
1: lo:  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:  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’ve confirmed the VM was created successfully from the template. We were also able to ssh into the instance.



Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.