
OpenVZ Philosophy
17
Understanding Templates
A template is a VPS building block. An OS template is a set of packages needed to operate a
VPS. Templates are usually created right on your Hardware Node; all you need is template tools
(
vzpkg
) and template metadata.
Template metadata
Template metadata are information
about
a particular OS template. It contains:
a list of packages included in this template (in the form of package names);
location of (network) package repositories;
distribution-specific scripts needed to be executed on various stages of template
installation;
public GPG key(s) needed to check signatures of packages;
All this information is contained in a few files installed into the
/vz/template/
osname
/
osrelease
/config/
directory. For example, the metadata for
the Fedora Core 4 template are installed into the
/vz/template/fedora-
core/4/config/
directory.
Along with template metadata, a few OpenVZ-specific packages are usually provided; they are
installed into the
/vz/template/
osname
/
osversion
/vz-addons/
directory.
Template cache
Template metadata provide enough information to create an OS template. During the OS
template creation, the needed package files are downloaded from the network repository to the
Hardware Node and installed into a temporary VPS, which is then packed into a gzipped tarball
called the
template cache
.
The template cache is used for fast VPS provisioning – basically, it is a pre-created VPS, so all
that is needed to create a VPS is to untar this file. The template cache files are stored in the
/vz/template/cache/
directory.
Any template cache becomes obsolete with time as new updates are released for the given
distribution. Naturally, there is a way to quickly update the template cache as well as all the
previously created VPSs with the newest updates.
While you are able to perform all kinds of tasks within a Virtual Private Server including
building
rpm
packages and installing them, OpenVZ provides an easy and far more efficient
way of installing the applications you need on VPSs. The same way as you install an OS
template on the OpenVZ system in order to create any number of Virtual Private Servers on its
basis and share its resources, you can install applications in OpenVZ in order to share package
files among any number of VPSs. You can then add these applications to any number of Virtual
Private Servers.
It goes without saying that in case you want to install an application on only one VPS, there is
no need in working with templates: you can as well work inside the corresponding VPS.