Steps to create minimal CentOS 6 container template:
1.Create a directory where the template files will be created
mkdir -p /var/lib/libvirt/lxc/centos-6-x86_64
2. Create yum repo folder within container root
mkdir -p /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/
3. Create CentOS repo
cat /etc/yum.repos.d/CentOS-Base.repo |sed s/'$releasever'/6/g > /var/lib/libvirt/lxc/centos-6-x86_64/etc/yum.repos.d/CentOS-Base.repo
4. Install core packages. --installroot param will install these packages into container root folder
yum groupinstall core --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y
5. Install any additional packages if required:
yum install plymouth libselinux-python --installroot=/var/lib/libvirt/lxc/centos-6-x86_64/ --nogpgcheck -y
6. Container can be configured further using chroot
chroot /var/lib/libvirt/lxc/centos-6-x86_64/
7. CloudStack requires template in tar.gz format. Create a tar.gz from container root /var/lib/libvirt/lxc/centos-6-x86_64/
cd /var/lib/libvirt/lxc/centos-6-x86_64/
tar -cvzf centos-6-x86_64.tar.gz *
8. centos-6-x86_64.tar.gz can be registered as a template in CloudStack