Sunday, June 26, 2011

Spacewalk provision Red Hat Linux by PXE kickstart

Spacewalk is an open source (GPLv2) Linux systems management solution. It is the upstream community project from which the Red Hat Network Satellite product is derived.
What can Spacewalk do:
- YUM repository Server, which is connected by client via yum-rhn-plugin
- Provision, kickstart, physical or virtual systems (using cobbler)
- Manage and deploy configuration files, software to a group of servers
- Monitor your systems (CPU, disk space etc .. ), Inventory your systems (hardware and software information)
OS supported by Spacewalk:
- Red Hat Linux derivatives (Centos, Fedora, Scientific Linux) and Solaris
- Limited support for SUSE Linux (AutoYaST Support is planned in V1.5, https://fedorahosted.org/spacewalk/roadmap )
- Experimental support for Debian (https://fedorahosted.org/spacewalk/wiki/Deb_support_in_spacewalk )
This post is not a complete guide for spacewalk install and administartion, its goal is to PXE kickstart a pysical server and have it registered to spacewalk server when kickstart complete. Kickstarting a server is easy but having it registered to spacewalk server needs tweaking.
Useful document for Spacewalk: 
http://wiki.centos.org/HowTos/PackageManagement/Spacewalk
https://fedorahosted.org/spacewalk/wiki/UserDocs
http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html
This post demonstrate spacewalk 1.4 kickstarting Centos 5.5 i386
Steps Summary:
- Setup PXE boot server environment
- Create OS base channel
- Create child channel(tools channel)
- Create distribution tree
- Create activation key
- Create kickstart profile
Setup PXE boot server environment
Setup tftp and dhcpd, refer to http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html
However, you don't bother editing pxelinux.cfg/default, which will be managed by spacewalk.
Create OS base channel
Navigate to: Channels | Manage software channels | Create new channel
Channel label is significant, It is channel label, not channel name, is referred for channel operations.
For GPG key section, refer to “GPG Sign RPM file” http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html
The GPG pub key need to copied to “/var/www/html/pub”, which can be downloaded by http://Server/pub/MY-GPG-FILE-NAME
#Import OS rpms to OS Base channel
#Before importing rpms, it is recommended to resign all rpms with your own GPG key “ rpm –resign *.rpm”, otherwise you need to import the rpm's original GPG key to all  clients.
$spacewalk-repo-sync  -c channel-label –-url  http://mirror.centos.org/centos/5/os/i386/
# You can also import rpms in installation media by –url file:///media/cdrom
Create child channel(tools channel)
Create a child channel for the Base channel created in last step, using same GPG information
#import spacewalk client rpms to the child channel
$spacewalk-repo-sync  -c child-channel-label  –-url  http://spacewalk.redhat.com/yum/1.4-client/RHEL/5/i386/
#python-ethtool doesn't exist in above sites, you need to download it manually from EPEL repository http://fedoraproject.org/wiki/EPEL  
#import a single rpm  to the child channel
$rhnpush  -c  child-channel-label  -u satadmin python-ethtool*.rpm 
Create distribution tree
Distribution hold installation files e.g. “images/stage2.img”, which can't be imported to spacewalk channel
#Create distribution tree path
$mkdir -p /var/distro-trees/centos-32-5.5
#Copy everything in installation media except for rpm files to the dir
#rpm files will be retrieved from channels
$cd /media/cdrom; find . ! -path "./CentOS/*"   | cpio -pvd /var/distro-trees/centos-32-5.5
Navigate to: Systems | Kickstart | Distributions | Create new distribution
dist2

Create activation key
Activation key is bound to base channel and entitlements, it is used by client to register to spacewalk without password authentication.
Navigate to: Systems | Activation Keys | Create new Key
Select the base channel and enable provisioning add-on entitlements
In child channels, select the child channel.
Optionally, if you want to pull configuration file e.g /etc/ntp.conf during kickstart, you need to create configuration channel and bind the activation key
Create kickstart profile
Navigate to: Systems | Kickstart | Create new kickstart profile
ks

In operating systems, select base channel and child channel
ks2
In Software,enter the  following packages in addition to @ Base
rhn-check
rhn-setup
yum-rhn-plugin
python-ethtool
python-dmidecode
rhncfg-client
rhncfg-actions
#Above packages provide rhnreg_ks and rhn_check to register to spacewalk during kickstart, otherwise kickstart postscript will encounter errors:
/tmp/ks-script-KOlpXy: line 128: rhnreg_ks: command not found
/tmp/ks-script-KOlpXy: line 134: rhn_check: command not found
#You can also write your own snipplets in “/var/lib/cobbler/snippets” to add packages dynamically.

In Activation Keys, select the activation key
Once kickstart profile is created, some entries are added to pxe configuration file
/tftpboot/pxelinux.cfg/default
Power on the server to be provisioned, when kickstart completed, It should be registered and appeared in spacewalk.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.