Archive for July, 2006

PXE for lazy sysadmins (part II - pflsa-0.0.1-alpha)

Saturday, July 29th, 2006

I finally got time and motivation to start writing pflsa. Code is pretty ugly. My PHP skills suck and it seems it prevents me from putting some decent logic in it. I will surely be rewritten, it’s still in proof-of-concept-mode.

What did change?

  • pxe_conf_url became pxe.conf.url and pxe_post_install_script_url is no longer used, moved to “${pxe.conf.url}?getscript”.

  • The configuration format changed too:
    1. It’s splitted in 3 parts %sysinstall, %packages and %post (a la kickstart ;-))
    2. in %sysinstall nothing changed. Except you can use ${size}K/M/G/T/P/E to define partition sizes, instead of number of sectors. installCommit is automatically added. If you have wishes about this part, ping me.
    3. %package target is just a list of packages. pflsa translates it into sysintall format.
    4. %post is actually a list of shell commands. When script is retrivied, pflsa will preprend shebang and few ready-to-go functions (to set timezone, enable services, set root password). I plan to add more functions: gmirror, adding users, etc. Here again, if you have ideas, ping me.


  • Per IP config support, with fallback to default.conf

  • Brownser friendly viewing (not yet finished and lamely based on User Agent).

  • I also add to pxe_crunch gdi (grab disk infos), with libdisk. I don’t really know if I’ll keep, do you need to inform pflsa about disk names/sizes?

If you want to have a look at pflsa files (source are not released yet, it’s too ugly ;)) it’s here.

Now it’s time for me to prepare dinner ;-) after that I’ll review gabor’s DESTDIR patch, and update apache ports.

PXE for lazy sysadmins (part I - proof of concept)

Thursday, July 27th, 2006

In few weeks, I’ll have to upgrade our 2 clusters from old customised redhat 7.3 linux to FreeBSD 6-STABLE. The preliminary tasks are already done: applications are now FreeBSD friendly, they have been ports-ified too, config files are ready to be deployed. It sounds really good doesn’t it? But I have a big constraint: I have to install one of the clusters in 3 hours. The only way to install ten servers in this timeframe is to use PXE. I already use PXE for basic installations, but here I must install ready-to-go servers. The cluster is also made of 3 different kinds of servers. I need to support different NICs, types of disk and even set up software RAID on one box. How can I do with our PXE stuff? I was dreaming of kickstart for FreeBSD ;-) I was thinking about patching sysinstall, but I’m too lazy :-) Let’s cheat!

(you can download a tarball with files and scripts here. Warning ! it’s quick and dirty !)

Prerequires:

  • FreeBSD source of the desired version

  • A FreeBSD ISO image

  • a Web and a FTP servers

  • a working PXE installation (Ceri’s post on PXE)

Basically, the idea is the to fetch a configuration file at the begining of sysinstall process, load it into sysinstall, commit install, fetch a post-install script and finally run it.

  1. Cook mfsroot (please read Ceri’s post to know how to play with it)
    First of all we have modify the mfsroot image to add fetch(1), our install.cfg and a simple script to fetch/configure our sysinstall.
    To add fetch, we need to regenerate boot_crunch to support fetch, like this one: pxe_crunch.conf.
    mkdir crunch

    cd crunch
    fetch http://www.cotds.org/~clement/PXE/part1/pxe_crunch.conf
    crungen pxe_crunch.conf
    make -f pxe_crunch.mk
    cd ..
    Mount mfsroot in a directory called mfsfd. Now we repopulate /stand with our new binary.cd mfsfd/stand
    rm *
    install 755 ../../crunch/pxe_crunch .
    for i in $(crunchgen -l ../../pxe_crunch.conf); do ln pxe_crunch ${i} ; done
    install m 755 /sbin/dhclientscript .
    Now we install our small install.cfg and the fetch_config.sh script fetch http://www.cotds.org/~clement/PXE/part1/install.cfg
    fetch http://www.cotds.org/~clement/PXE/part1/fetch_config.sh
    chmod +x fetch_config.sh
    cd ..
    mkdir -p var/db tmp var/run

    Umount mfsroot and copy it in you boot/ directory in your nfs share.
  2. Populate web server
    On your webserver, install pxe.conf and pxe.sh
    mkdir ${DOCUMENTROOT}/pxeinstall
    cd
    ${DOCUMENTROOT}/pxeinstall
    fetch http://www.cotds.org/~clement/PXE/part1/pxe.conf
    fetch http://www.cotds.org/~clement/PXE/part1/pxe.sh

    Edit those files to suit your needs.
    vi pxe.conf pxe.sh

    If you want to install FreeBSD via the interface PXE used, keep %%IFNAME%% as netDev value.
    Currently disk support is not yes available. It will be supported soon.
    pxe.sh is executed in post-install stage so you can use previously installed stuff, like perl or so. It’s a live system so beware :)
    Note: don’t put stuff in /etc/rc.conf, it will be commented out. Use /etc/rc.conf.local instead.
    Note 2: you can put those file on the FTP server instead.
  3. Populate FTP server
    mkdir ${FTPROOT}/pub/FreeBSD/releases/i386/
    tar xvf /path/to/6.1-RELEASE-i386-disc1.iso 6.1-RELEASE ${FTPROOT}/pub/FreeBSD/releases/i386/

  4. Edit boot/loader.rc
    We use loader.rc to set 2 variables: pxe_conf_url and pxe_post_install_script_url.
    Your loader.rc shoud look like this:
    load /boot/kernel/kernel
    load -t mfs_root /boot/mfsroot
    set vfs.root.mountfrom=”ufs:/dev/md0c”
    set pxe_conf_url=”http://www.yourwebserver.org/pxeinstall/pxe.conf”
    set pxe_post_install_script_url=”http://www.yourwebserver.org/pxeinstall/pxe.sh”
    boot

  5. The end
    Boot your machine via PXE and it should be ok :-)

The future is to replace hard-coded pxe.conf et pxe.sh for a php script to generation config file/script on the fly. pxe.sh should be improved to make gmirror configuration, nss stuff, and more (like data restoration via bacula for example). I’ll surely add more functions when it get rewriten.

FYI, I use my own FreeBSD release, packages are built in marcuscom tinderbox and a script to generate INDEX file. I also use a meta-port to avoid polluting pxe.conf.

See ya for part II… if any :-)