tigerlinux.github.io

TigerLinux technical recipes for IT survival

UNATTENDED INSTALLATION TEMPLATES FOR CENTOS, DEBIAN AND UBUNTU.

Introduction.

Both RHEL and DEBIAN based distros can be installed non-interactivelly by the use of “templates” which include all installation options. Those options include:

Debian-based distros use “preseed”, while RHEL based use “anaconda”.

Each of those installation tools (preseed/anaconda) have it’s own rules and config options that when used with a “preseed file” (debian’s) or “kickstart file” (rhel’s), basically produces the same results: A ready-to-use machine !.

This is basically an “unattended” installation !. This installation philosophy have many advantages over interactive installations. We can mention a few:

What will you find here ?.

The “unattended” section here contains the following directories:

In each template directory, you’ll find templates that includes:

Each template file is very well documented, with usage instructions for each case.

Template usage - Normal “non-cloudinit” servers:

In each template you’ll find the instructions very well commented at the beginning of the file, but basically you’ll need to boot your machine with the “netinstall” installation disk (or ISO if you are using any virtalization tool like kvm/qemu, virtmanager o virtualbox), then press ESCAPE (or “TAB” in the case of Ubuntu 16.04lts), then input the installation options as mentioned on the template.

From there, just go for a coffee and enjoy the show !.

Template usage - Cloud-init templates:

The “cloud-init” based templates (the one’s with “openstack-seed-cloud” as part of their filename) are a special case. Those are used specifically for openstack-glance images generation (not bare-metal server).

Normally, what we want to do is create a “qcow” file that later we’ll include on OpenStack. So.. how do we use those templates ?. Easy:

First, using qemu-img, create a image file. Example:

qemu-img create -f qcow2 centos-6-32-cloud.qcow2 30G

That last command created the file “centos-6-32-cloud.qcow2” image, representing a “virtual hard disk” with 30 Gigabytes max space.

Then, using qemu/kvm, create a virtual machine that will use this image as main hard disk. This command assumes you have the NetInstall ISO at hand in the same directory where your “qcow” file is located (CentOS-6.7-i386-netinstall.iso):

kvm \
-m 2048 \
-cdrom CentOS-6.7-i386-netinstall.iso \
-drive file=centos-6-32-cloud.qcow2,if=virtio \
-net nic,model=virtio \
-net user \
-nographic \
-vnc :9 \
-k es \
-usbdevice tablet \
-smp cpus=2 \
-balloon virtio

Stop here in order to understand some of the options we passed to the kvm command:

After you start your KVM based VM, connect to it using VNC (any windows-or-linux vnc client will do), to the real-machine IP and display 9 (unless you changed -vnc :X to another display).

Then once you’re inside your KVM-Based Virtual Machine, just use the template with the instructions at the beggining of the kickstart/preseed file (press ESC or TAB depending on the case, and input the options needed for the automated installation).

The cloud-init-openstack based template will do all it’s stuff, and then “poweroff” the machine, so, when finish the “kvm” command you just used will exit normally.

The resulting qcow2 file is basically your server image. The next step is, compress the server image. You can doit using the following command:

qemu-img convert -c -O qcow2 -p centos-6-32-cloud.qcow2 centos-6-32-cloud-compressed.qcow2

Finally, include your qcow2 “compressed” image to OpenStack glance (asumming newer openstack versions and using openstack cli instead of glance cli):

openstack image create "Centos-6-32-Cloud" \
	--disk-format qcow2 \
	--public \
	--container-format bare \
	--project YOUR_OPENSTACK_PROJECT \
	--protected \
	--file centos-6-32-cloud-compressed.qcow2

The OpenStack cloud images contain specific options for a cloud-init based cloud (specially OpenStack):

Installation sources.

All templates uses mirrors from the distribution. That ensures the installed server will be up-to-date with all O/S updates at creation time. The apt/yum also keeps those mirrors so you can ensure your server will be always updated (as long as you remember to do proper maintenance of course !).

You can, using those templates as base, create your own internal infrastructure with no internet-dependency, just by creating a local copy of my “unattended” structure, create a local mirror for your desired distros, and modifying the url’s inside the templates in order to use your local mirror and local copies of the unattended support files.

Please note the following for each O/S if you want to have your own mirror infrastructure:

Finally, if you want to create your own cloud-init-based-to-be-used-with-openstack templates, remember: DO NOT use lvm if you intend to use the auto-resize options in your openstack instances. Also, try to stick with EXT4 in “at least” “/boot” and “/” partitions. You can use other filesystems in your secondary disks, but, for the primary-root-disk, use ext4 !.

Software-RAID Templates.

Along the templates for LVM, you’ll find some software-raid-lvm templates too. Those are hard-coded with sda/sdb, so, if your device mapping is different, clone the repo and make your own adjustments.

End.-