Using variables in kickstart file

Michael DeHaan mdehaan at redhat.com
Wed Jul 18 19:47:16 UTC 2007


Ed Brown wrote:
> Cobbler might be a bigger hammer than is needed, and PXE/DHCP isn't 
> always an option, especially in distributed network environments.  If 
> you're installing the OS over the network (as opposed to cd's), and 
> are able to burn/boot from cd to initiate the install, there's 
> possibly not a simpler approach to kickstarting and static ip 
> addressing than to make a boot cd with a custom syslinux.cfg file with 
> the common boot parameters (method, ks, netmask, dns) and just provide 
> the ip and gateway at the anaconda 'boot:' prompt.

Slightly OT, but ...

Adam Wolf contributed a fairly nice CGI to help with this recently ... 
http://feelslikeburning.com/projects/live-cd-restoring-with-cobbler/    
You may want to mentally read "live CD" here as "restore disk".   A 
modification of what he posted is in the upstream codebase now as 
"findks.cgi".    Or, you can completely ignore that and still use 
cobbler and a restore disk, just hard coding the URLs.

There's also a real live CD (buildable from the koan source checkout) 
that acts as a universal installer -- so from one Live CD, depending on 
the system MAC, it can install the correct distro for the system -- and 
the distro doesn't even have to match the distro of the media you are 
using.   Over time, you can redefine what each system needs to get 
installed on it, and you'll never have to reburn that one CD as new 
distros get added or you change the OS that a certain machine should be 
running ... it just /knows/.   Anyhow, this is useful because, just like 
in the restore disk boot scenario -- a lot of people don't have a PXE 
configuration -- and we can support that too.

Anyhow, I disagree that Cobbler is too big of a hammer -- a hammer is a 
pretty simple tool, and it's designed to fulfill the needs of small 
setups just as much as the datacenter case -- for instance, in my 
office, PXE provisioning isn't viable because I don't own DHCP, but I 
can still use the other features.    It's worth checking out and it only 
takes a few commands to get the above environment running from scratch 
-- and then you get full templating for it out of the box.    I would 
definitely say using /all/ of Cobbler isn't worth it, but you don't have 
to use /all/ of it.  If you just want to use it to maintain kickstarts 
and don't intend to use the PXE portions, that's fine.

It also does Xen, QEMU/KVM (new), and reinstalling existing machines -- 
all things that you may also want templating for.   So, in adopting 
something a bit more flexible now, you get options later.

My main point is that it's /not/ just a PXE setup tool.   Is that one of 
the primary uses?   Sure.


>
> in your kickstart file:
> network  --bootproto=static
>
> copy the isolinux/ directory from your distro
> edit isolinux/isolinux.cfg and create custom entry:
> label custom
>   kernel vmlinuz
>   append initrd=initrd.img text nofb dns=your.nameserver.ip 
> netmask=255.255.255.0 ks=<url.of.ks.cfg> method=<url.of.distro>
>
> make a bootable iso:
> mkisofs -o boot.iso  -b isolinux.bin -c boot.cat -no-emul-boot 
> -boot-load-size 4 -boot-info-table -R -J -T -v isolinux/
>
> burn cd:
> cdrecord boot.iso
>
> to install, boot from cd, and enter arguments at boot prompt
> boot:  custom ip=<your.server.ip> gateway=<your.gateway.ip>
>
> Within %post, hostname is available like this:
> hostname=`grep HOSTNAME /etc/sysconfig/network |cut -d'=' -f2`
> Note that the hostname was not provided at kickstart time, it came 
> from DNS.
>
> And I haven't tried it, but as Chip suggested, the ip, if you need it, 
> should be available by processing /proc/cmdline, something like:
> ip=`cat /proc/cmdline |perl -e 'if (<> =~ /\sip=(.*?)\s/) {print $1}'`
>
> -Ed
>
>
>
> Gabrie wrote:
>> Would you have an example of that?
>>
>> I now set the variables in the %post section and then they are
>> available in the scripts. But I can't use them in the "network"
>> section.
>>
>> Gabrie
>>
>>
>> On 7/18/07, Shabazian, Chip <Chip.Shabazian at bankofamerica.com> wrote:
>>> You could also add these variables to the boot: line and then pull them
>>> from /proc/cmdline in the %pre section.  Just make sure you have 255
>>> characters or less for that boot: line.
>>>
>>> -----Original Message-----
>>> From: kickstart-list-bounces at redhat.com
>>> [mailto:kickstart-list-bounces at redhat.com] On Behalf Of Gabrie
>>> Sent: Wednesday, July 18, 2007 2:55 AM
>>> To: Kickstart-list at redhat.com
>>> Subject: Using variables in kickstart file
>>>
>>> Hi
>>>
>>> I'm going to install about 20 servers, which will be identical apart
>>> from hostname and IP address. To make changes in all ks files easier, I
>>> would like to start using one central batch file, that is being called
>>> from the ks.cfg file. Therefore I would like to use 2 variables
>>> containing IP and hostname.
>>>
>>> Ideally it would be something like this:
>>>
>>> ### Begin ks020.cfg
>>> VAR-IP = 10.0.0.20
>>> VAR-HOST = vmesx020.mydomain.com
>>>
>>> <snip>
>>>
>>> network --device eth0 --bootproto static --ip $VAR-IP --netmask
>>> 255.255.255.0 -gateway 10.0.0.254 --hostname $VAR-HOST
>>>
>>> <snip>
>>>
>>> %post
>>> # download central script
>>> lwp-download http://10.0.0.1/scripts/central.cfg /tmp/central.cfg
>>>
>>> perl /tmp/central.cfg $VAR-IP $VAR-HOST
>>>
>>> ### End ks020.cfg
>>>
>>>
>>> In the central.cfg I would then be able to read the VAR-IP and VAR-HOST
>>> and use it for other configuration stuff.
>>>
>>> Who can tell me how to use variables in this way? I have the feeling
>>> there also is a difference between a variable in the first section
>>> (network section) and the post section????
>>>
>>> Gabrie
>>>
>>> _______________________________________________
>>> Kickstart-list mailing list
>>> Kickstart-list at redhat.com
>>> https://www.redhat.com/mailman/listinfo/kickstart-list
>>>
>>> _______________________________________________
>>> Kickstart-list mailing list
>>> Kickstart-list at redhat.com
>>> https://www.redhat.com/mailman/listinfo/kickstart-list
>>>
>>
>> _______________________________________________
>> Kickstart-list mailing list
>> Kickstart-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/kickstart-list
>
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list




More information about the Kickstart-list mailing list