VMware Cloud Community
Bhanta
Contributor
Contributor

Commands to add vSwitch, portgroup etc arn't being applied from custom ks.cfg file

All,

I have almost managed to create an iso image with my custom ks.cfg file injected into it. However i am now falling over at what i think is the last hurdle so was wondering if somebody could assist. The problem i am having is that my build completes fully but unfortuently the networking commands (e.g creating a vSwitch or adding a port group etc) arn't being applied. Other settings such as hostname, ip addres of service console which i have setup my ks.cfg to prompt for and configure dynamically seem to work.

One interest thing i noticed is that if i open up the /etc/ntp.conf on the esx server all the commands and comments under the "server ntp.domain.com" line in my ks.cfg file seem to be entered into this file - AS A RESULT im not sure if ive got a syntax problem in my kickstart file.

My ks.cfg file contains the following (i have taken out gateway, nameserver, ntp server name etc)

accepteula

keyboard uk

firewall --allowOutgoing

firewall --allowIncoming

  1. Read network information from a file we are going to populate in the %pre section

  2. of this kixstart script.

%include /tmp/networkconfig

auth --enablemd5 --enableshadow

install cdrom

rootpw --iscrypted $1$bayw34kz$cwHzrtubh9N.NZjf

timezone --utc 'Europe/London'

  1. Read partition information from a file we are going to populate in the %pre section

  2. This allows me to create local vmfs with "hostname:storage1" and I've adjusted the sizes

  3. on my service console partitions.

%include /tmp/partconfig

%pre --interpreter=bash

#################################

      1. Get network information ###

#################################

  1. Clear screen prior to prompting for input and change to virtual terminal 1

  2. vSphere will only work on tty1 to read input

exec </dev/tty1 >/dev/tty1

chvt 1

header ()

{

clear

echo

echo "################################################################"

echo "### VMWare ESX 4.0 Scripted Install ###"

echo "################################################################"

echo

}

  1. Get user input

while ;do

header

echo -n "Please Enter FQDN for ESX Host: "

read fqdn

done

while ;do

header

echo -n "Please Enter Service Console IP Address: "

read ipnew

done

  1. Change back to tty 6 to watch progress on packages

chvt 6

  1. Let's cut the fqdn suffix off the hostname so we can name the vmfs partition

  2. named something like this: "hostname:storage1"

temp_host=`echo $fqdn | cut -f1 -d"."`

  1. Now we are going to save of partition information using the new vmfs volume name

  2. so that it can be used by Weasel install

cat <<EOF> /tmp/partconfig

  1. Use first detected disk:

clearpart --firstdisk --overwritevmfs

part '/boot' --fstype=ext3 --size=1100 --onfirstdisk

  1. Uncomment to use first detected disk:

#part '/boot' --fstype=ext3 --size=1100 --onfirstdisk

part 'none' --fstype=vmkcore --size=110 --onfirstdisk

  1. Uncomment to use first detected disk:

#part 'none' --fstype=vmkcore --size=110 --onfirstdisk

part 'Storage1' --fstype=vmfs3 --size=9208 --grow --onfirstdisk

  1. Uncomment to use first detected disk:

#part 'Storage1' --fstype=vmfs3 --size=9208 --grow --onfirstdisk

virtualdisk 'esxconsole' --size=8208 --onvmfs='Storage1'

part 'swap' --fstype=swap --size=1204 --onvirtualdisk='esxconsole'

part '/var/log' --fstype=ext3 --size=2000 --onvirtualdisk='esxconsole'

part '/' --fstype=ext3 --size=5000 --grow --onvirtualdisk='esxconsole'

EOF

  1. Write the networkconfig file to be used by the Weasel install

  2. Using the "--addvmportgroup=0" option because another script will define my specific port groups

cat <<EOF> /tmp/networkconfig

network --device=vmnic2 --bootproto=static --ip=$ipnew --netmask=255.255.255.0 --gateway=XXX.XX.XX.XXX --nameserver=XXX.XX.XX.XXX --hostname=$fqdn --addvmportgroup=true

EOF

  1. Need an extra post section that is not chrooted to save my variables from PRE

%post --nochroot

%post --interpreter=bash

##########################################################

  1. Allow hostd etc. some time to load

/usr/bin/sleep 90

  1. ntp settings

esxcfg-firewall --enableService ntpClient

chkconfig ntpd on

cat > /etc/ntp.conf <<EOF

  1. ---- ntp.conf ----

  2. Created by Weasel (ESX Installer)

  1. Permit time synchronization with our time source, but do not

  2. permit the source to query or modify the service on this system.

restrict default kod nomodify notrap nopeer noquery

restrict -6 default kod nomodify notrap nopeer noquery

server ntp.domain.com

        1. ADD a nic to vSwitch0 (second one for service console)

/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch0

        1. Create a new vSwitch called vSwitch_VLAN2

/usr/sbin/esxcfg-vswitch -a vSwitch_VLAN2

        1. ADD a portgroup called CustomVLAN to the vSwitch called vSwitch_VLAN2

/usr/sbin/esxcfg-vswitch -A CustomVLAN vSwitch_VLAN2

/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch_VLAN2

        1. Delete the port group called VM Network from vSwitch0

/usr/sbin/esxcfg-vswitch -D "VM Network" vSwitch0

0 Kudos
2 Replies
Bhanta
Contributor
Contributor

Sorry didnt know that the formatting of my ks.cfg would be messy

I've attached a txt file with the config details....if somebody could give it a once over then that would be great!

0 Kudos
Rajeev_S
Expert
Expert

Hi,

You could try adding the below commands in the ks and try,

For SC

/usr/sbin/esxcfg-vswif --ip Award Points if helpful!!

0 Kudos