Fixing "grubby fatal error: unable to find a suitable template"

When I saw Kimsufi (OVH) offering a fully dedicated server at £3 a month, I had to give it a try. However, when trying to do a standard install of OpenVZ on CentOS 6.4 (this issue is also exhibited with a simple stock kernel, as below), this wouldn't properly configure grub (a quick Google suggests it's down the customisations that OVH enforce on their Linux deployments).

For example:

$ sudo yum install kernel
... lots of output ...
grubby fatal error: unable to find a suitable template
... lots more output ...

Fortunately, this is easy to fix (because OVH offers a nice rescue mode should you mess it up). You'll just need to modify /boot/grub/grub.conf manually, and add the entry as the first one (assuming default=0). Just remember to prefix the relevant filenames with /boot/, OpenVZ example:

title OpenVZ (2.6.32-042stab081.5)
        blog_jay_sh (hd0,0)
        kernel /boot/vmlinuz-2.6.32-042stab081.5 blog_jay_sh=/dev/sda1  ro
        initrd /boot/initramfs-2.6.32-042stab081.5.img

A quick sanity check, before rebooting:

$ ls -sh /boot/initramfs-2.6.32-042stab081.5.img
14M /boot/initramfs-2.6.32-042stab081.5.img

$ ls -sh /boot/vmlinuz-2.6.32-042stab081.5
3.9M /boot/vmlinuz-2.6.32-042stab081.5