Tuesday, April 1, 2014
After installing Cobbler and importing the Ubuntu Server 12.04.4 LTS ISO, I copied the Cobbler Profile created on import into a new one named ubuntu-12.04.4-server-x86_64-ks with the intention of pointing it to the following kickstart profile (yes, Ubuntu supports kickstart profiles but only so much):
install text url --url=$tree lang en_US.UTF-8 keyboard us network --device eth0 --bootproto dhcp timezone --utc UTC zerombr clearpart --all --initlabel bootloader --location=mbr part /boot --fstype=ext3 --size=256 --asprimary part pv.01 --size=1024 --grow --asprimary volgroup vg_root pv.01 logvol swap --fstype swap --name=lv_swap --vgname=vg_root --size=1024 logvol / --fstype=ext4 --name=lv_root --vgname=vg_root --size=1024 --grow auth --enableshadow --enablemd5 rootpw --iscrypted CHANGE_ME user --disabled firewall --disabled skipx reboot %packages ubuntu-minimal openssh-server curl git
I saved the kickstart profile above to /var/lib/cobbler/kickstarts/ubuntu-server-12.04.ks and ran the following command to point Cobbler Profile ubuntu-12.04.4-server-x86_64-ks at the kickstart profile:
cobbler profile edit --name=ubuntu-12.04.4-server-x86_64-ks --kickstart=/var/lib/cobbler/kickstarts/ubuntu-server-12.04.ks
The above command completed successfully but just to verify the modification worked, I ran
cobbler profile dumpvars --name=ubuntu-12.04.4-server-x86_64-ks | grep kickstart, and sure enough, the kickstart attribute now pointed to /var/lib/cobbler/kickstarts/ubuntu-server-12.04.ks.
However, when attempting to PXE boot a server, the server would reboot, go into PXE boot mode, get an IP from the DHCP server, but skip the actual PXE booting and boot to the local hard drive.
To make sure the kickstart file was actually being pulled, I opened /var/lib/tftpboot/pxelinux.cfg/default looked for the LABEL ubuntu-12.04.4-server-x86_64-ks line and copied the URL after auto url=.
I ran that URL through curl with the following command:
The curl output returned the following error:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>500 Internal Server Error</title> </head><body> <h1>Internal Server Error</h1> <p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p> <p>Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.</p> <p>More information about this error may be available in the server error log.</p> <hr> <address>Apache/2.2.22 (Ubuntu) Server at 192.168.0.100 Port 80</address> </body></html>
Clearly something was wrong with the kickstart profile because when the same Cobbler Profile used the sample.ks kickstart profile instead of my own, the curl command would output the kickstart profile contents fully parsed.
cobbler validateks but it did not return anything wrong.
Finally, when I ran
cobbler profile getks --name=ubuntu-12.04.4-server-x86_64-ks it bombed out and returned the following error:
<type 'exceptions.UnicodeDecodeError'>:'ascii' codec can't decode byte 0xe2 in position 472: ordinal not in range(128)
Something appeared to be wrong with the formatting of the file. Opening the file with vim and setting it to show invisible characters did not reveal anything out of the ordinary.
So, I ran
file /var/lib/cobbler/kickstarts/ubuntu-server-12.04.ks and it returned UTF-8 Unicode text while running
file /var/lib/cobbler/kickstarts/sample.ks returned ASCII English text. I did not understand what was causing the ubuntu-server-12.04.ks file to be encoded as UTF-8 Unicode text, so I proceeded to figure out how to convert UTF-8 to ACSII.
After reading through the above post, I ran
iconv -f utf8 -t ascii ubuntu-server-12.04.ks. It parsed and outputted some of the file but bombed out halfway through with the following error:
iconv: illegal input sequence at position 447
Where the iconv command stopped parsing was the key to figuring out what was wrong.
The iconv command stopped parsing on the auth line right after the word auth, so this told me something was wrong with the hyphens. Upon closer inspection of the hyphens, they were indeed wrong.
Take a look at the following screenshot:
Go to the auth line and look very closely at the first hyphen for enableshadow and enablemd5. They are slightly longer than the second hyphen.
Those elongated hyphens are apparently not ASCII encoded text and somehow stuck around during the copy and pasting lifetime of this kickstart profile. The moment I removed those hypens, re-typed them, and saved the file, the file was now encoded as ASCII English text (I didn’t need to use the iconv command) and the PXE boot process worked.