I'd like to Kickstart a couple dozen RHEL6/SL6 servers. However, some of these servers are different and I don't want to create a new ks.cfg file for each class of server.

Is there any way I can generate a Kickstart file dynamically on the fly, from a template?

For example, if I append a line like this to the Kernel:

APPEND ks= ip=dhcp

Then the script ks.cgi can determine what host this is (Via the MAC address), and print out Kickstart options which are appropriate for that host. I could optionally override some options by passing parameters to the script, like this:


After we kickstart the server, we activate Cfengine/Puppet on this system and manage the system using our favorite Configuration Management product.

We're experimenting with xCAT but it is proving too cumbersome. I've looked into Cobbler, but I'm not sure it does this.


A roll-your-own solution is discussed in the O'Reilly book: Managing RPM-Based Systems with Kickstart and Yum, Chapter 3. Customizing Your Kickstart Install > Dynamic ks.cfg, which echos some of the comments in this thread:

To implement such a tool is beyond the scope of this Short Cut, but I can walk through the high-level design. Any such solution would mix a data store (the things that change) with a templating solution (the things that don’t change). The data store would hold the per-machine data, such as the IP address and hostname. You would also need a unique identifier, perhaps the hostname, such that you could pick up a given machine’s data. The data store could be a flat file, XML data, or a relational database such as PostgreSQL or MySQL.

In turn, to invoke the system, you pass a machine’s unique identifier as a URL parameter. For example:

boot: linux ks=http://your.kickstart.server/gen_config?host-server25

In this example, the CGI (or servlet, or whatever) generates a ks.cfg for the machine server25.

But where, oh where, is the code for ks.cgi?

  • Interesting question. What kind of kickstart parameters are you looking to change dynamically? Oct 19, 2011 at 0:01
  • @Beaming: I'm not sure exactly, but I think I would mostly want to change the 'class' of server with something like NODETYPE=production or NODETYPE=development. Oct 19, 2011 at 0:16
  • 1
    Not really an answer, but just serving up a different kickstart script based on some URL parameters is pretty trivial PHP. It might be easier to develop this yourself then find some other software to do it for you.
    – devicenull
    Oct 19, 2011 at 1:42
  • 1
    @awsiv - it is not cool to go editing old questions with tags for the product from the company that you work for. You can and should suggest answers, and disclose your connection. Adding edits to a question looks link-whory and very very bad.
    – mfinni
    Aug 14, 2012 at 1:12
  • 1
    Cobbler's built-in system should be perfectly sufficient to the task. Oct 15, 2012 at 2:06

3 Answers 3


Since you are already using puppet, you can also take a look at Foreman for advanced kickstart templating.

Foreman uses ruby templating, allowing flexible kickstart templating.

  • We're not actually using puppet (we're stuck on Cfengine 2. We are thinking of moving to Puppet, but that looks like a big task). Dec 22, 2011 at 16:28
  • Since you're talking about Foreman don't stop there, have a look at Katello as well for end to end systems management.
    – Red Tux
    Dec 22, 2011 at 16:40

I have a simple proprietary solution deployed where I use PHP as the templating language and the kickstart file is generated on the fly by a PHP script on a local server.

The process to create such a thing is very simple if you know how to write kickstart files (see this Red Hat documentation if you want to learn how):

  1. Create your basic kickstart file (with some default values for the parameters you wish to "templatize").
  2. Save the kickstart to a file on your webserver with a .php extension. I use -kickstart.php
  3. Add PHP code in the kickstart file to read URL parameters and setup the correct data, then replace your default values from step 1 with the output from PHP variables

for example, replace

network --device eth0 --bootproto dhcp --hostname SOME_STATIC_HOSTNAME


network --device eth0 --bootproto dhcp --hostname <?php echo $hostname;?>

That's basically it.

I wanted to have pretty URLs so the boot loader says something like:

linux ksdevice=eth0 ks=http://myserver/kickstart/rhel6/networkname/servername/ks.cfg

with all the parameters specified as path elements. For that I created an .htaccess file for the Apache webserver that looks like this:

RewriteEngine On
RewriteBase /kickstart
RewriteRule kickstart/(.*) /company-kickstart.php/$1

Then the PHP script does something like this:

list($empty,$os,$envtype,$hostname,$notimportant) = 
header("Content-Type: text/plain"); # important, otherwise kickstart fails
# Kickstart file automatically generated by my script.
#version=<?php echo $os;?>
url --url=http://my.local.mirror/<?php echo $os;?>/os/x86_64
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp --hostname <?php echo $hostname;?>
# ... rest of kickstart parameters

Cobbler supports kickstart profiles, but kickstart works very well with PHP, so you can pass parameters in your ks=... line. You may end up scripting this yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.