One of the easiest ways to deploy a virtual machine in oVirt is first to install the OS then turn it into a template. This will allow you to copy that template to deploy new instances. One mundane task after a new template is copied to a new instance is logging in, changing the IP, setting the hostname, setting up Puppet, running puppet, etc.
cloud-init is the tool designed to fix that mundane task process by allowing those steps to be automated. oVirt/RHEV (as well as OpenStack, AWS, and others) allow you to pass in user data which is then supplied to
cloud-init after the template is copied over and turned on. This allows for scripting on the new VM – easing deployment.
For my environment, I wanted a CentOS 7 template. To have that, I must first install CentOS on a new VM and seal it (Windows calls this Sysprep). Before I seal it, I must install
cloud-init and any other tools I might use for deployment – such as
puppet. Here are the steps to obtain just that:
* Install CentOS 7.2 Minimal on any new VM. Ensure to have LVM partitioning as you may want to extend the disk later. I have found that 10 GB is a good starting size.
* Install your base files – things you cannot live without (i.e.
* Seal the VM per RedHat instructions. I suggest following the instructions for sysunconfig:
- Log in to the virtual machine.
- Remove ssh host keys:
# rm -rf /etc/ssh/ssh_host_*
/etc/sysconfig/networkfor Red Hat Enterprise Linux 6/CentOS 6 or
/etc/hostnamefor Red Hat Enterprise Linux 7/CentOS 7.
- Remove the
- Optionally, delete all the logs from
/var/logand build logs from
sys-unconfig will turn off the VM when it is completed. When it is turned off, right click the VM and select copy to template.