Professional Documents
Culture Documents
Note: this series of articles applies to CentOS 6; for CentOS 5, see this series.
CentOS (and of course, it's upstream distro, Red Hat Enterprise Linux) has an extremely powerful, but somewhat poorly documented, tool for rapidly deploying machines
and managing their configuration: kickstart. Kickstart lets you build a custom installation that can run hands-free. So not only is the installation quick and easy for you, you
can be confident that your machines are configured exactly the way you want them to be.
Imagine that you have 25 web servers (or a mix of web servers, database servers, mail servers, etc.). It would be highly desirable to install identical software packages on
all of those machines. In that way, you know that any application you build will run the same way on all machines.
If you use the standard install DVD, achieving such uniformity can be challenging. During the installation, it's always possible that you might accidentally select a different
mix of packages for one machine, especially if you are not using one of the standard installation types. Further, it's quite likely that for your production environment you might
need some additional packages that are not part of the standard CentOS distribution. For example, in our environment, we add apps
like aide, analog, httperf, ganglia,iptraf, memcached, nagios, and swatch. If you have to add these packages manually after installation, you'll spend a lot of time,
and you might overlook a machine or a package, leading to inconsistent behavior down the road.
In addition to your software packages, you will likely need to make various system and software configurations. For example, you may need to configure httpd or mysql, or
maybe you need to add a group to /etc/groupor a user to /etc/passwd. It is critical that these configurations be done consistently on all machines.
The solution is to predefine your package selections with kickstart and let the automated installer guarantee the installation of the same applications on all machines.
Further, the postinstaller capabilities of kickstart will allow you to install non-distro applications and perform any system configuration that you can do from a shell script.
If you want to make your life really easy, you can set up your kickstart to run from a single DVD.
http://smorgasbork.com/component/content/article/35-linux/128-building-a-custom-centos-6-kickstart-disc-part-1
1/2
8/20/2014
IDE drives, and your target might use SCSI, or you may want to use software RAID on the target machine), you'll have to edit some of these lines. When you're getting
started, it's easiest if you use a build machine configured identically to your target machine.
http://smorgasbork.com/component/content/article/35-linux/128-building-a-custom-centos-6-kickstart-disc-part-1
2/2
8/20/2014
Note: this series of articles applies to CentOS 6; for CentOS 5, see this series.
Once you've decided which packages you're going to include in your kickstart disc, it's time to pull them all together.
Which RPMs do you need? Assuming that you are including at least the @core and @base package groups (and you should), you'll need the RPMs for all the packages in
those groups.
One way to obtain the list of RPMs you need is to look in the file comps.xmlfor the core and base groups. You will see XML like this:
<group>
<id>core</id>
<name>Core</name>
...
<packagelist>
<packagereq type="default">Deployment_Guide-en-US</packagereq>
<packagereq type="mandatory">SysVinit</packagereq>
<packagereq type="mandatory">authconfig</packagereq>
<packagereq type="mandatory">basesystem</packagereq>
<packagereq type="mandatory">bash</packagereq>
<packagereq type="mandatory">centos-release</packagereq>
<packagereq type="mandatory">coreutils</packagereq>
<packagereq type="mandatory">cpio</packagereq>
...
</packagelist>
</group>
At a bare minimum, you will want all the required packages from within the baseand coregroups. Look for <packagereq type="mandatory">and <packagereq
type="default"> entries within the <group>tags. This tells you which packages to get. These package names correspond to the names of the RPM files.
To make this easier, I have built a script to parse the comps.xmlfile and gather all the non-optional packages for the baseand corepackage groups.
Downloadparse_comps.pland save it in your ~/kickstart_build/utilsdirectory.
Before you can run parse_comps.pl, you'll need to install some perl libraries:
cd ~/kickstart_build/all_rpms
sudo rpm -Uvh \
perl-Compress-Raw-Zlib-2.023-119.el6.x86_64.rpm \
perl-Compress-Zlib-2.020-119.el6.x86_64.rpm \
perl-HTML-Parser-3.64-2.el6.x86_64.rpm \
perl-HTML-Tagset-3.20-4.el6.noarch.rpm \
perl-IO-Compress-Base-2.020-119.el6.x86_64.rpm \
perl-IO-Compress-Zlib-2.020-119.el6.x86_64.rpm \
perl-libwww-perl-5.833-2.el6.noarch.rpm \
perl-URI-1.40-2.el6.noarch.rpm \
perl-XML-Parser-2.36-7.el6.x86_64.rpm \
perl-XML-Simple-2.18-6.el6.noarch.rpm
Run it this way:
cd ~/kickstart_build/isolinux/Packages
~/kickstart_build/utils/parse_comps.pl ~/kickstart_build/comps.xml ~/kickstart_build/all_rpms x86_64
Gather dependencies
Now we have all the baseand coreRPMs in our ~/kickstart_build/isolinux/Packagesdirectory, along with any other RPMs you've added, but many are missing
their dependencies. So the next step is to track down all the dependencies of these packages and throw those into the directory, too. You can use another
script,follow_deps.pl, to perform this step.
http://smorgasbork.com/component/content/article/35-linux/129-building-a-custom-centos-6-kickstart-disc-part-2
1/2
8/20/2014
cd ~/kickstart_build/isolinux/Packages
~/kickstart_build/utils/follow_deps.pl ~/kickstart_build/all_rpms x86_64
Testing dependencies
Once you've got a set of RPMs ready, you'll need to test the dependencies of the RPMs. Each RPM may require that other RPMs be installed in order for it to be installed. If
each RPM's dependencies are included in the set of RPMs, then all the dependencies are resolved. The objective is to have a set of RPMs that have no unresolved
dependencies.
To test the dependencies in your set of RPMs, run these commands:
mkdir /tmp/testdb
rpm --initdb --dbpath /tmp/testdb
rpm --test --dbpath /tmp/testdb -Uvh *.rpm
If you find you have unresolved dependencies (and you will almost certainly have some), you can do one of two things:
remove the RPM with the unresolved dependencies (a good idea if the RPM is going to set off a chain of dependencies that you don't want, for example X Windows on
a server class installation)
track down the RPMs to fulfill the dependency
Here, again, you need a little bit of savvy to determine which packages should be removed. In general, if the package is one that you explicitly added to the base and core
groups, then you'll probably want to find the dependencies and include them. If it's an RPM that you don't really want (one that got matched by the wildcard, for example), you
might decide to eliminate that RPM.
Resolving dependencies
The follow_deps.plscript should get all your dependencies automatically. But if it doesn't (and it might not, especially if you've added some additional RPMs to the mix),
you'll have to track down the dependencies manually.
Finding the RPMs to satisfy dependencies can be easier said than done. Sometimes the capability dependencies listed don't match the name of the RPM. For example, you
might get something like:
/usr/bin/strip is needed by redhat-lsb-3.1-12.3.EL.el5.centos.x86_64
It turns out that /usr/bin/stripis provided by binutils.
If you're not sure what RPM provides one of these dependencies, you can use RPM itself to query for the right package (assuming the right package is installed on the
queried system -- this is where it is very helpful to have a machine that has all the RPMs installed).
rpm -q --whatprovides /usr/bin/strip
This is an iterative process. Be prepared to spend a while chasing down these dependencies to build a fine-tuned collection of RPMs with no unresolved dependencies.
The next step is to build your disk image. I will cover that in the next installment.
http://smorgasbork.com/component/content/article/35-linux/129-building-a-custom-centos-6-kickstart-disc-part-2
2/2
8/20/2014
Note: this series of articles applies to CentOS 6; for CentOS 5, see this series.
Now that you've compiled your RPMs, you need to build a disk image from which to perform the kickstart.
http://smorgasbork.com/component/content/article/35-linux/130-building-a-custom-centos-6-kickstart-disc-part-3
1/1
8/20/2014
Note: this series of articles applies to CentOS 6; for CentOS 5, see this series.
Let's make things really interesting with a postinstall script to do some custom configuration.
http://smorgasbork.com/component/content/article/35-linux/131-building-a-custom-centos-6-kickstart-disc-part-4
1/2
8/20/2014
Put your non-CentOS application RPMs and tarballs into apps(with a subdirectory for each application), put application configuration files and scripts
into appconfig(again with a subdirectory for each application), put OS configuration files (like network config files) into sysconfig, and put general-purpose libraries
(those not specifically required by any applications you're installing) into libs.
Of these strategies, the organization of appsis by far the most important. When you install applications that are not part of the CentOS distro, you'll likely have to install
additional libraries or utilities to satisfy dependencies in those packages. When you need to refresh your kickstart image, it is helpful to have each app and its
dependencies contained in a single directory. If you throw them all into a big directory, you'll never remember, for example, that mhash is in there because aide requires it.
External repositories
I have found the following repositories to be reliable sources of packages that aren't included in the CentOS distro:
EPEL - Extra Packages for Enterprise Linux
repoforge - formerly RPMforge; DAG repository now redirects to this
ATrpms - good place to get ffmpeg rpms
ELrepo - source for hardware drivers
Good luck building your custom installation disc. I welcome any comments or suggestions you might have for this guide!
http://smorgasbork.com/component/content/article/35-linux/131-building-a-custom-centos-6-kickstart-disc-part-4
2/2