From the previous articles the following has been setup:
Now to actually install a redhat vm.
Cobbler needs to know about the system, so use cobbler system add to create the system. The mac, ip address, name etc will depend on the network environment.
cobbler system add --name=<system name> \
--profile=redhat-5.5-xen-i386 --hostname=<hostname> \
--dns-name=<fqdn> --ip-address=XXX.XXX.XXX.XXX \
--mac=random
The profile links to redhat.ks which uses a lot of snippets to work. Make sure all the snippets referenced in the kickstart are copied or linked into /var/lib/cobbler/snippets. redhat.ks uses snippets like base_install and post_install_script.
To install on virtual hardware, install koan on the Dom0. Koan stands for “kickstart over network”. The following command will retrieve the configuration for the system registered in cobbler as vm9 and use libvirt to kickstart the system.
koan --server <cobbler server> --virt \
--system=<system name> --virt-name=<hostname> --virt-type=xenpv \
--virt-path=<path to disk> --vm-poll
Now lots of things happen. Here is an attempt to make a timeline of everything that is going on.
Koan connects to cobbler server and retrieves all system information: ip, mac, dns name, kernel and initrd, etc.
Koan downloads kernel and initrd as provided by cobbler distro definition
Koan uses libvirt to create a vm install configuration. This references the local kernel and initrd and uses the kernel command line generated by Cobbler. This includes a reference to the kickstart or preseed.
Libvirt converts xml definition into xen sxp (lisp like configuration language used by xen) and boots the vm.
Libvirt waits until vm is booted and then creates another vm configuration, this time for post install configuration. This uses the bootloader pygrub which retrieves the kernel from the disk. This configuration will not become active until the vm currently running the installer exits and the vm shuts down.
Koan started with –vm-poll option waits for vm to exit. It polls vm every minute and executes xm start when vm is stopped. This is part of making install fully automated.
Meanwhile the vm is running the install kernel. Installer uses DHCP to get IP address from dnsmasq as generated by cobbler. The installer then downloads the post template processed kickstart from cobbler. If the kickstart is setup properly the installer will require no user intervention. To see a graphical installer in action, use vncviewer to connect to port 5900 of the Xen Dom0 host. If the vm is the second vm running on the system use port 5901, etc.
Installer partitions and formats disk, installs packages and bootloader, runs post install scripts and then shuts down. The installer says reboot, but this would prevent new vm config from becoming active and would restart installer.
Post install vm config becomes active and vm can be started using xm start or by waiting for koan to detect stopped vm.
Pygrub bootloader reads grub.cfg from disk and loads kernel from vm disk and xen boots vm using this configuration.
VM boots and probably uses DHCP from dnsmasq to get IP address.
To become ready for use, the vm runs puppet from the /etc/rc.local script. This is setup in the kickstart post install script. Puppet then configures the vm for the appropriate role. Usually roles are assigned to hostname patterns.
Frankly every time I do this I am amazed it even works. With a little attention to the kickstart, the install is completely hands off.
Now cobbler’s role in this is essentially finished. Now puppet and mcollective manage the vm though its lifecycle.