[CentOS] PXE boot, Kickstart NFS install and %include...

Donald Murray, P.Eng. donaldm314 at gmail.com
Tue Mar 14 22:53:21 UTC 2006


On 3/14/06, Will McDonald <wmcdonald at gmail.com> wrote:
> On 14/03/06, Aleksandar Milivojevic <alex at milivojevic.org> wrote:
> > Quoting Will McDonald <wmcdonald at gmail.com>:
> >
> > > I was just wondering how (or indeed if) people use the %include
> > > directive in Kickstart configuration files when building systems via
> > > NFS. I've been trying to modularise our Kickstart files a little to
> > > make things more readable, having generic defaults and role specific
> > > stuff split out into separate configs.
> >
> > The %include directives are parsed two times by Anaconda.  First time
> > before %pre scripts are executed, and then after %pre scripts are
> > executed.  The missing files are ignored on the first parsing of
> > kickstart file.  However, Anaconda will complain if they are missing
> > when it parses the file for the second time (just after %pre scripts
> > are executed).  This allows you to create those files dynamically from
> > the %pre scripts (or make them accessible if already stored somewhere).
> >  You must ensure that all files referenced by %include directives
> > exist and are accessible by the time %pre scripts finish (for example,
> > by creating the file in %pre script or by NFS mounting the directories
> > where they live from %pre script).
> >
> > If else fails, you can always copy the files locally using %pre script...
>
> Excellent, I hadn't thought of using %pre but from the sounds of it
> that'll allow me to keep all the configs broken out into sections.
>
> Cheers Aleksandar.
>
> Will.
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>

Another useful trick is to pass options in via the kickstart
command-line. Within your %pre and %post you can read these options
from /proc/cmdline, then source them into your script. For example, we
use this to configure static IPs without having to hard-code them.

Consider the following three lines:
cat /proc/cmdline | sed 's/ /\
export /g' | grep '^export myemployer_' | grep = > /tmp/myemployer_cfg
source /tmp/myemployer_cfg

If the kickstart command-line included
'myemployer_staticip=192.168.0.42 myemployer_foobar=exnage', the
contents of myemployer_cfg would be:
myemployer_staticip=192.168.0.42
myemployer_foobar=exnage

After you've source'd /tmp/myemployer_cfg, the variables
$myemployer_staticip and $myemployer_foobar will be available to you.



More information about the CentOS mailing list