Alan Pevec
2008-Aug-20 23:41 UTC
[Ovirt-devel] [PATCH] configure Cobbler instance in oVirt appliance
Minimal Fedora install tree is imported into the image during appliance creation, at appliance firstboot Cobbler distro and profiles are created, using non-mirrored repositories to save appliance disk space and setup time. Cobbler entries for each "fake" oVirt Node in developer setup is added if you add more oVirt Nodes, define them as Cobbler system: cobbler system add --name=NodeName --profile=oVirt-Node-x86_64 --mac=00:11:22:33:44:55 --netboot-enabled=1 otherwise they will PXE boot to the default Cobbler boot menu, where oVirt Node can be manually choosen Signed-off-by: Alan Pevec <apevec at redhat.com> --- wui-appliance/Makefile | 9 +++++- wui-appliance/gettree.sh | 31 ++++++++++++++++++ wui-appliance/wui-devel.ks | 75 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletions(-) create mode 100755 wui-appliance/gettree.sh diff --git a/wui-appliance/Makefile b/wui-appliance/Makefile index ea0bb61..ace0b8c 100644 --- a/wui-appliance/Makefile +++ b/wui-appliance/Makefile @@ -1,11 +1,13 @@ NAME=ovirt-appliance YUMCACHE=$$(pwd)/../tmp/cache +F_REL := $(shell rpm -q --qf '%{VERSION}' fedora-release) +ARCH := $(shell uname -i) appliance: $(NAME)-sda.raw appliance-compressed: $(NAME)-sda.qcow -$(NAME)-sda.raw: wui-devel.ks common-install.ks common-pkgs.ks common-post.ks repos.ks +$(NAME)-sda.raw: *.ks tmp/tree/.treeinfo mkdir -p tmp appliance-creator --config wui-devel.ks --name $(NAME) \ --tmpdir="$$(pwd)/tmp" --cache="$(YUMCACHE)" @@ -17,6 +19,11 @@ $(NAME)-sda.qcow: $(NAME)-sda.raw repos.ks: ../common/repos.ks.in cp ../common/repos.ks.in repos.ks +tmp/tree/.treeinfo: + mkdir -p tmp/tree + cd tmp/tree; ../../gettree.sh \ + http://download.fedoraproject.org/pub/fedora/linux/releases/$(F_REL)/Fedora/$(ARCH)/os + clean: rm -f repos.ks diff --git a/wui-appliance/gettree.sh b/wui-appliance/gettree.sh new file mode 100755 index 0000000..f6b01a8 --- /dev/null +++ b/wui-appliance/gettree.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# gettree.sh <Fedora release URL> +# Fedora release URL - Fedora base URL +# e.g. http://download.fedoraproject.org/pub/fedora/linux/releases/9/Fedora/x86_64/os +# download minimal Fedora tree: .treeinfo stage2 initrd and kernel + +download() { + local f=$1 + wget --progress=dot:mega --continue $1 + printf "." +} + +if [ -z "$1" ]; then + cat >&2 << EOF +Usage: $(basename "$0") <Fedora release URL> +EOF + exit 1 +fi + +url=$1 +printf "Downloading minimal Fedora install tree from $url" +set -e +download $url/.treeinfo +mkdir -p images/pxeboot +cd images +download $url/images/stage2.img +cd pxeboot +download $url/images/pxeboot/initrd.img +download $url/images/pxeboot/vmlinuz +echo "done" diff --git a/wui-appliance/wui-devel.ks b/wui-appliance/wui-devel.ks index 66927be..cb49b6b 100644 --- a/wui-appliance/wui-devel.ks +++ b/wui-appliance/wui-devel.ks @@ -290,3 +290,78 @@ chmod +x /etc/init.d/ovirt-wui-dev chkconfig ovirt-wui-dev on %end + +%post --nochroot + # distribution tree is ready in tmp/tree + set -e + python -c ' +from iniparse.ini import INIConfig +ini = INIConfig() +fp = open("tmp/tree/.treeinfo") +ini.readfp(fp) +fp.close() +family = ini.general.family +version = ini.general.version +arch = ini.general.arch +print "%s %s %s" % (family, version, arch)' | ( read os ver arch + dest=$INSTALL_ROOT/var/www/cobbler/ks_mirror/$os-$ver-$arch + printf "Importing $os-$ver-$arch ..." + cp -a tmp/tree $dest + cat >> $INSTALL_ROOT/etc/rc.d/rc.cobbler-import << EOF +#!/bin/sh +# Import Cobbler profiles on first boot + +exec > /root/cobbler-import.log 2>&1 + +# run only once +chmod -x \$0 +set -x +cobbler import --name=$os-$ver --arch=$arch \ + --path=/var/www/cobbler/ks_mirror/$os-$ver-$arch +cobbler repo add --name=f9-$arch --arch=$arch --mirror-locally=0 \ + --mirror=http://download.fedoraproject.org/pub/fedora/linux/releases/9/Everything/$arch/os +cobbler repo add --name=f9-$arch-updates --arch=$arch --mirror-locally=0 \ + --mirror=http://download.fedoraproject.org/pub/fedora/linux/updates/9/$arch +cobbler profile edit --name=$os-$ver-$arch --repos="f9-$arch f9-$arch-updates" + +# TODO extract Node boot params from /var/lib/tftboot/pxelinux.cfg/default +# before Cobbler overwrites it +cobbler distro add --name="oVirt-Node-$arch" --arch=$arch \ + --initrd=/var/lib/tftpboot/initrd0.img --kernel=/var/lib/tftpboot/vmlinuz0 \ + --kopts="rootflags=loop root=/ovirt.iso rootfstype=iso9660 ro console=tty0 console=ttyS0,115200n8" +cobbler profile add --name=oVirt-Node-$arch --distro=oVirt-Node-$arch +cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \ + --name=node3 --mac=00:16:3e:12:34:57 +cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \ + --name=node4 --mac=00:16:3e:12:34:58 +cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \ + --name=node5 --mac=00:16:3e:12:34:59 +set +x +echo "Add new oVirt Nodes as Cobbler systems to make them PXE boot oVirt Node image directly." +echo "Alternatively, choose oVirt-Node-$arch in default Cobbler boot menu." +EOF + chmod +x $INSTALL_ROOT/etc/rc.d/rc.cobbler-import + echo "[ -x /etc/rc.d/rc.cobbler-import ] && /etc/rc.d/rc.cobbler-import" \ + >> $INSTALL_ROOT/etc/rc.d/rc.local + echo done + ) +%end + +# Cobbler configuration +%post + exec >> /root/kickstart-post.log 2>&1 + # ovirt/ovirt + echo ovirt:Cobbler:68db208a546dcedf34edf0b4fe0ab1f2 > /etc/cobbler/users.digest + # make cobbler check happier + mkdir -p /etc/vsftpd + touch /etc/vsftpd/vsftpd.conf + mkdir -p /usr/lib/syslinux + cp /var/lib/tftpboot/pxelinux.0 /usr/lib/syslinux/pxelinux.0 + # TODO use Augeas 0.3.0 Inifile lens + sed -i -e "s/^module = authn_denyall.*/module = authn_configfile/" \ + /etc/cobbler/modules.conf + sed -i -e "s/^server:.*/server: '192.168.50.2'/" \ + -e "s/^next_server:.*/next_server: '192.168.50.2'/" \ + /etc/cobbler/settings + sed -i -e '/kernel /a \\tIPAPPEND 2' /etc/cobbler/pxesystem.template +%end -- 1.5.5.1
Perry N. Myers
2008-Aug-21 00:34 UTC
[Ovirt-devel] [PATCH] configure Cobbler instance in oVirt appliance
Alan Pevec wrote:> Minimal Fedora install tree is imported into the image during appliance creation, > at appliance firstboot Cobbler distro and profiles are created, > using non-mirrored repositories to save appliance disk space and setup time. > > Cobbler entries for each "fake" oVirt Node in developer setup is added > if you add more oVirt Nodes, define them as Cobbler system: > cobbler system add --name=NodeName --profile=oVirt-Node-x86_64 --mac=00:11:22:33:44:55 --netboot-enabled=1 > otherwise they will PXE boot to the default Cobbler boot menu, where > oVirt Node can be manually choosenHad a conversation with Alan on IRC about this, but wanted to document here... This patch means that the admin has to run "cobbler system" for each new Node. This adds an extra manual step to adding a new Node to a network. Here's a way around that (not for this patch, but for another subsequent patch) 1. Node initial boot goes to default PXE menu which has Node image as an option. On first boot admin selects Node image 2. Node boots and registers with the oVirt Server and during registration the Server creates a cobbler system with the MAC address of the Node so that subsequent boots of the new box always default to the Node image Only thing that is bad about this setup is that for nodes with no keyboard/mouse/display (rack mount boxes) there's no way to select Node from the PXE default menu. In this case the admin needs to either manually add the system with the MAC before booting the first time as Alan instructs above. Or the Admin needs to configure cobbler so that the default option is the Node instead of Local Disk. We'll just need to provide instructions for doing this. Perry
Ian Main
2008-Aug-21 03:53 UTC
[Ovirt-devel] [PATCH] configure Cobbler instance in oVirt appliance
On Thu, 21 Aug 2008 01:41:42 +0200 Alan Pevec <apevec at redhat.com> wrote:> Minimal Fedora install tree is imported into the image during appliance creation, > at appliance firstboot Cobbler distro and profiles are created, > using non-mirrored repositories to save appliance disk space and setup time. > > Cobbler entries for each "fake" oVirt Node in developer setup is added > if you add more oVirt Nodes, define them as Cobbler system: > cobbler system add --name=NodeName --profile=oVirt-Node-x86_64 --mac=00:11:22:33:44:55 --netboot-enabled=1 > otherwise they will PXE boot to the default Cobbler boot menu, where > oVirt Node can be manually choosenPerry and I spent a lot of time messing about with this one. Turns out the config is not picked up for some bizarre reason until you restart cobbler. We tried cobbler sync too with no success. Here is what I added and it tested and worked fine: --- a/wui-appliance/wui-devel.ks +++ b/wui-appliance/wui-devel.ks @@ -336,6 +336,7 @@ cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \ --name=node4 --mac=00:16:3e:12:34:58 cobbler system add --netboot-enabled=1 --profile=oVirt-Node-$arch \ --name=node5 --mac=00:16:3e:12:34:59 +service cobblerd restart set +x echo "Add new oVirt Nodes as Cobbler systems to make them PXE boot oVirt Node image directly." echo "Alternatively, choose oVirt-Node-$arch in default Cobbler boot menu." If you add that, it all works fine on boot up. I'm installing fedora now! ACK with that change. :) Ian