Cobbler and the Dell OpenManage Deployment Toolkit #2

Cobbler and the Dell OpenManage Deployment Toolkit was a quick example of getting the DTK set up to boot via Cobbler. This post will add the ability to automatically register the system with cobbler and assign it to a hardware-specific profile. When you have a bunch of systems automatically added to Cobbler, you will just have to apply those configurations that make each host unique (like hostname and IP address).

Once this step is mastered, we can go a bit further in the next post and add customization of the BIOS, BMC, and RAID configurations.

The methods being used here, with separate directories for each tool, allow for, well… separation. You could make one directory, download all the RPMs, extract them, and create one big script to copy them to the booted DTK environment. The below method better allows for upgradability, separates out dependencies, and is self-documenting.

Assumptions:

  • Instructions in the first post were followed.
  • Tools like wget and rpm2cpio are installed.
  • Your workflow for kickstarting systems is a little more complex than: netboot the new server, pick a Cobbler menu item, enjoy your new system. *

* My $EMPLOYER uses multiple hardware models and configurations for a single application. We roll an entire cabinet of new hardware into our datacenter and then power it all up. Our workflow allows for discovery and classification of the hardware models and looks like: netboot the new server (preferably this is the default on new hardware); automatically boot to a default discovery + configuration + regisitration profile; once they appear in Cobbler, manually assign Hostname/IP Address/Kickstart Metadata to each system; wait for each system to reboot and load OS; puppet picks up OS configuration and application installation; enjoy our new systems.

Instructions:
Set up some directories for future use:

cd /srv/nfs/ro/dtk-3.5.1/
mkdir data_files scripts addons

First, we are going to prepare the addons that do not ship with the DTK.

cd addons

Create an install tree for dmidecode. This tool will be useful to gather hardware details that Dell’s syscfg tool may not pick up on unsupported models (like the C6100 Cloud series).

mkdir dmidecode
cd dmidecode
cat <<EOF >create
#!/bin/bash
cd \`dirname \$0\`
wget http://mirror.centos.org/centos/5/os/i386/CentOS/dmidecode-2.11-1.el5.i386.rpm
rpm2cpio dmidecode-2.11-1.el5.i386.rpm | cpio -ivdm ./usr/sbin/*
EOF
chmod +x create
./create

cat <<EOF >install
#!/bin/bash
cd \`dirname \$0\`
for X in usr/sbin/*; do
  cp -p \${X} /\${X}
done
EOF
chmod +x install
cd ..

Create an install tree for koan. This tool provides cobbler-register which is the whole point of this exercise.

mkdir koan
cd koan
cat <<EOF >create
#!/bin/bash
cd \`dirname \$0\`
wget http://download.fedora.redhat.com/pub/epel/5/i386/koan-2.0.11-2.el5.noarch.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/python-urlgrabber-3.1.0-6.el5.noarch.rpm
wget http://mirror.centos.org/centos/5/os/i386/CentOS/rhpl-0.194.1-1.i386.rpm
rpm2cpio koan-2.0.11-2.el5.noarch.rpm | cpio -idmv ./usr/bin/* ./usr/lib/python2.4/*
rpm2cpio python-urlgrabber-3.1.0-6.el5.noarch.rpm | cpio -idmv ./usr/bin/* ./usr/lib/python2.4/*
rpm2cpio rhpl-0.194.1-1.i386.rpm | cpio -idmv ./usr/lib/python2.4/*
EOF
chmod +x create
./create

cat <<EOF >install
#!/bin/bash
cd \`dirname \$0\`
for X in usr/bin/* usr/lib/python2.4/site-packages/*; do
  #cp -p \${X} /\${X}
  ln -s \${X} /\${X}
done
EOF
chmod +x install
cd ..

Next, we are going to create some scripts to automate discovery of hardware and register with Cobbler.

cd ../scripts

This script will detect some basic hardware details like the server model name and serial number.

cat <<EOFM >detect.sh
#!/bin/bash

\${TOOLKIT_MNTPNT}/addons/dmidecode/install

#export PRODUCT_NAME=\`syscfg --sysname | awk -F= '{print \$2}'\`
export PRODUCT_MANUFACTURER=\`dmidecode -s system-manufacturer\`
export PRODUCT_NAME=\`dmidecode -s system-product-name\`
export PRODUCT_LNAME=\`echo $PRODUCT_NAME | sed -e 's| ||g'\`
export PRODUCT_SNAME=\`echo $PRODUCT_NAME | sed -e 's|PowerEdge ||' -e 's|poweredge ||'\`
export SERIAL_ID=\`dmidecode -s system-serial-number\`
export ASSET_TAG=\`dmidecode -s chassis-asset-tag\`
export ARCH=

cat <<EOF

*** Detecting system type ***

   System Information:
       Name      : \$PRODUCT_NAME
       Serial    : \$SERIAL_ID
       Arch      : \$ARCH
       LNAME     : \$PRODUCT_LNAME
       SNAME     : \$PRODUCT_SNAME
       Asset Tag : \$ASSET_TAG
EOF

EOFM
chmod +x detect.sh

This script will call the detection script and then register with Cobbler. This script is based off of work done on customizations to the HP SSSTK scripts.

cat <<EOF >install_yourapp.sh
#!/bin/bash

export TOOLKIT_MNTPNT=/opt/dell/toolkit/systems
export TOOLKIT_SERVER_IP=\`echo \$share_location | awk -F: '{print \$1}'\`

. \${TOOLKIT_MNTPNT}/scripts/detect.sh

if ! echo "\$PRODUCT_MANUFACTURER" | grep -qi Dell; then
  echo "**************************************************"
  echo "**************************************************"
  echo "**************************************************"
  echo "WARNING: This is not a known hardware.  Halting..."
  echo "**************************************************"
  echo "**************************************************"
  echo "**************************************************"
  echo "\$PRODUCT_NAME"
  /bin/poweroff
  #exec /bin/bash

  # FIXME to do something useful with non-Dell hardware.
fi

echo ""
echo "** Registering with cobbler"
\${TOOLKIT_MNTPNT}/addons/koan/install
# DTK already removes spaces from Proliant names, but not VMware.
PRODUCT_LNAME=\`echo \$PRODUCT_LNAME | sed -e 's| ||g'\`
# PRODUCT_LNAME = PowerEdgeR610, PowerEdgeC2100, C6100, etc.
echo "** Registering to profile \${cprofile}-\${PRODUCT_LNAME}"
cobbler-register --batch --server=\${TOOLKIT_SERVER_IP} --profile=\${cprofile}-\${PRODUCT_LNAME} --fqdn=\${SERIAL_ID}
echo ""

echo ""
echo "** Rebooting"
ipmitool chassis bootdev pxe
sleep 5
reboot
EOF
chmod +x install_yourapp.sh

Create another Cobbler profile with specific details about your application:

sudo cobbler profile add --name=dtk-3.5.1-install_yourapp \
--parent=dtk-3.5.1-shell --enable-menu=yes \
--kopts 'share_script=scripts/install_yourapp.sh cprofile=yourapp'

Then create separate profiles for each hardware type that you will be registering with Cobbler. This allows you to set hardware-specific items like the kickstart file that will be used to load the OS.

sudo cobbler profile add --name=yourapp-PowerEdgeR610 \
--distro=CentOS6.2-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/yourapp_dellr610.ks \
--comment="Dell PowerEdge R610" --enable-menu=no
sudo cobbler profile add --name=yourapp-PowerEdgeC2100 \
--distro=CentOS6.2-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/yourapp_dellc2100.ks \
--comment="Dell PowerEdge C2100" --enable-menu=no
sudo cobbler profile add --name=yourapp-C6100 \
--distro=CentOS6.2-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/yourapp_dellc6100.ks \
--comment="Dell PowerEdge C6100" --enable-menu=no

Now when you power up your new Dell on a Cobbler-managed network and manually choose the dtk-3.5.1-install_yourapp Cobbler menu item, you will end up with a system registered to the correct hardware profile with all of it’s NIC MAC addresses programmed in Cobbler. From that point, you can add IP addresses and hostname details, enable Netboot, and your OS will start loading.

cobbler system edit --name=SERIALNUMBER --netboot-enabled \
--ip=192.168.1.50 --hostname=MyNewHost
Advertisements

About Michael Arnold
This is where I write about all of my unix hacking experiences so that you may be able to learn from my troubles.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: