Mike-S
Contributor
Contributor

Kickstart Debug

Hi,

I have been trying to script the install of my ESX servers using a kickstart file (ks.cfg). I used the script creator tool in ESX to create a basic file which worked fine. I have now edited the %post section to setup all my virtual switches and port groups. When I run my modified ks.cfg file to perform a scripted install it works and installs ESX but fails to create any of the virtual switches and ports groups.

There must be a syntax error or something wrong with the %post section.

Is there a tool available which can detect errors in ks.cfg files?

Thanks

0 Kudos
5 Replies
depping
Leadership
Leadership

Can you post the first bit of the script. The problem is probably that you are trying to run these commands directly from the ks.cfg file which isn't possible. Take a look at the script I wrote almost a year ago:

http://www.yellow-bricks.com/2008/06/27/scripted-install/

You will probably need to add the following directly after %post

cat > /tmp/esxcfg.sh <

#!/bin/sh

<insert scripted config here>

EOF1

/bin/chmod 755 /tmp/esxcfg.sh

cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

cat >> /etc/rc.d/rc.local <

cd /tmp

/tmp/esxcfg.sh

mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local

EOF

Duncan

VMware Communities User Moderator

-


Blogging: http://www.yellow-bricks.com

Twitter:

If you find this information useful, please award points for "correct" or "helpful".

wayne_gregory
Contributor
Contributor

I am not aware of any but here is what I put in the %post section

  1. Create vSwitch1 for VM traffic with a port group of VM-Network-Data1 using vmnic1, vmnic3, vmnic4 and vmnic5

esxcfg-vswitch -a vSwitch1

esxcfg-vswitch -L vmnic1 vSwitch1

esxcfg-vswitch -L vmnic3 vSwitch1

esxcfg-vswitch -L vmnic4 vSwitch1

esxcfg-vswitch -L vmnic5 vSwitch1

esxcfg-vswitch -A VM-Network-Data1 vSwitch1

esxcfg-vswitch -p VM-Network-Data1 -v 109 vSwitch1

  1. Create vSwitch2 for VMotion traffic a port group of VM-Network-VMotion using vmnic2

#esxcfg-vswitch -a vSwitch2

#esxcfg-vswitch -L vmnic2 vSwitch2

#esxcfg-vswitch -A VM-Network-VMotion vSwitch2

#esxcfg-vmknic -a -i 192.168.0.11 -n 255.255.255.0 VM-Network-VMotion

#esxcfg-vswitch -p VM-Network-VMotion -v 1002 vSwitch2

HTH

0 Kudos
depping
Leadership
Leadership

again, run all commands from a second script which gets launched by rc.local... it will make your life a lot easier, it's the way everyone has been doing it for years.

Duncan

VMware Communities User Moderator

-


Blogging: http://www.yellow-bricks.com

Twitter:

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
BenConrad
Expert
Expert

The key concept to understand is that %post is running commands inside the RHEL installation routine. RHEL doesn't know anything about ESX or any esxcfg-* commands.

Most kickstart scripts use the %post section to build a temporary /etc/rc.d/rc.local script which runs on first boot. That first boot is now running ESX so your esxcfg-* command will work. After all commands in rc.local are complete most people will revert to the original rc.local so the server doesn't re-run all the commands you only wanted to run on first boot.

For example:

  1. Build your rc.local script using commands available to the RHEL installer

cat >> /tmp/build.sh << EOF1

#!/bin/sh

/usr/sbin/esxcfg-vswitch -l

  1. when done running all your custom commands, switch back to the original rc.local

cp --reply=yes -p /etc/rc.d/rc.local.sav /etc/rc.d/rc.local

EOF1

  1. done building rc.local commands

  1. backup existing rc.local

cp -p --reply=yes /etc/rc.d/rc.local /etc/rc.d/rc.local.sav

  1. create rc.local for use on first boot

echo "/tmp/build.sh" >>/etc/rc.d/rc.local

  1. End of %post

Ben

BUGCHK
Commander
Commander

esxcfg-vswitch & friends require that the VMkernel is loaded, but it is not present during the initial kickstart. That's why people have to delay it after the first boot of the installed ESX system. As shown, a separate script is prepared and /etc/rc.d/rc.local is modified to run the script during boot.

Enjoy to wonderful world of automated installation!

0 Kudos