VMware Cloud Community
halibut
Enthusiast
Enthusiast
Jump to solution

VI3.5 Kickstart problem

I create a kickstart script and anything within the standard commands works fine, however I can't get any of the post installation commands to work. If I add --vmnic0 to the networking field the install script exits prematurely. My hope was that this would be used instead of continually backing up the Host OS on ESX.

snip

  1. Auto-Generated Scripted Install Configuration file.

  2. This file is used for VMware ESX Server Scripted Install Deployment

  1. Installation Method

url --url=http://[UDA_IPADDR]/[OS]/[FLAVOR]

  1. root Password

rootpw --iscrypted 'not displayed'

  1. Authconfig

auth --enableshadow --enablemd5

  1. BootLoader ( The user has to use grub by default )

bootloader --location=mbr

  1. Timezone

timezone America/Edmonton

  1. X windowing System

skipx

  1. Install or Upgrade

install

  1. Text Mode

text

  1. Network install type

network --device=vmnic0 --bootproto dhcp --addvmportgroup=0

  1. Language

lang en_US

  1. Langauge Support

langsupport --default en_US

  1. Keyboard

keyboard us

  1. Mouse

mouse none

  1. Reboot after install ?

reboot

  1. Firewall settings

firewall --disabled

  1. Clear Partitions

clearpart --all --initlabel --drives=sda

  1. Partitioning

part /boot --fstype ext3 --size 200 --ondisk sda --asprimary

part / --fstype ext3 --size 10240 --ondisk sda --asprimary

part swap --size 1600 --ondisk sda --asprimary

part /var --fstype ext3 --size 10240 --ondisk sda

part /var/log --fstype ext3 --size 10240 --ondisk sda

part /home --fstype ext3 --size 10240 --ondisk sda

part /tmp --fstype ext3 --size 10240 --ondisk sda

part /vmimages --fstype ext3 --size 5120 --ondisk sda

part None --fstype vmkcore --size 110 --ondisk sda

part None --fstype vmfs3 --size 1 --grow --ondisk sda

  1. VMware Specific Commands

vmaccepteula

%packages

@base

@ everything

%post

#Add user for ssh connectivity

/usr/sbin/useradd console

/usr/sbin/usermod -p password console

#Modify DNS Config

cat > /etc/resolv.conf << EOF

search companyname

nameserver x.x.x.x

nameserver x.x.x.x

EOF

#Modify NTP Config

chkconfig --level 345 ntpd on

cat > /etc/ntp.conf << EOF

restrict 127.0.0.1

restrict default kod nomodify notrap

server x.x.x.x

driftfile /var/lib/ntp/drift

EOF

cat > /etc/ntp/step-tickers << EOF

172.22.20.20

EOF

/sbin/chkconfig --level 345 ntpd on

/sbin/service ntpd start

/sbin/hwclock --systohc

#MOTD Restriction Banners

cat > /etc/restricted_access << EOF

Logging onto a Restricted Server - UNAUTHORIZED ACCESS PROHIBITED

EOF

echo Banner /etc/restricted_access >> /etc/ssh/sshd_config

  1. VMNetworking

/usr/sbin/esxcfg-vswitch --add vSwitch0:64

/usr/sbin/esxcfg-vswitch --add-pg="Service_Console" vswitch0

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic0 vSwitch0 --pg="Service_Console"

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic2 vSwitch0 --pg="Service_Console"

/usr/sbin/esxcfg-vswitch --add vSwitch1:64

/usr/sbin/esxcfg-vswitch --add-pg="vMotion" vswitch1

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic3 vSwitch1 --pg="vMotion"

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic7 vSwitch1 --pg="vMotion"

/usr/sbin/esxcfg-vswitch --add vSwitch2:128

/usr/sbin/esxcfg-vswitch --add-pg="Prod_v100" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="Prod_v100" --vlan=100

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="Prod_v100" --vlan=100

/usr/sbin/esxcfg-vswitch --add-pg="Prod_v21" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="Prod_v21" --vlan=21

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="Prod_v21" --vlan=21

/usr/sbin/esxcfg-vswitch --add-pg="VMInternal_v4094" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="VMInternal_v4094" --vlan=4094

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="VMInternal_v4094" --vlan=4094

/usr/sbin/esxcfg-vswitch --link=vmnic0 vSwitch0

/usr/sbin/esxcfg-vswitch --link=vmnic2 vSwitch0

/usr/sbin/esxcfg-vswitch --link=vmnic3 vSwitch1

/usr/sbin/esxcfg-vswitch --link=vmnic7 vSwitch1

/usr/sbin/esxcfg-vswitch --link=vmnic1 vSwitch2

/usr/sbin/esxcfg-vswitch --link=vmnic4 vSwitch2

perl -p -i -e 's/teamPolicy\/maxActive = "."/teamPolicy\/maxActive = "2"/g' /etc/vmware/esx.conf

  1. Configure Command Queue Depth

if grep "QLogic" /etc/vmware/esx.conf ; then

/usr/sbin/esxcfg-module -s ql2xmaxqdepth=128 qla2300_707_vmw

fi

/usr/sbin/esxcfg-advcfg -s 128 /Disk/SchedNumReqOutstanding

/usr/sbin/esxcfg-advcfg -s 1 /Disk/UseLunReset

/usr/sbin/esxcfg-advcfg -s 0 /Disk/UseDeviceReset

/usr/sbin/esxcfg-boot -b

  1. Set Memory for Service Console to 512 MB

/usr/bin/vimsh -n -e "hostsvc/memoryinfo 536870912"

snip

Any Thoughts?

0 Kudos
1 Solution

Accepted Solutions
BenConrad
Expert
Expert
Jump to solution

Best practice is to cat everything into a .sh file and then on first boot you switch rc.local to use that .sh file, then at the end of the .sh file you swap back rc.local so on final boot the server boots normally.

Also, you can't run any commands that use the vmkernel during the kickstart, the vmkerel is not loaded. In v4, the vmkernel is loaded during scripted builds.

  1. Everything between the << EOF1 and EOF1 will be echoed to /tmp/build.sh

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

#!/bin/sh

mydate=`date +"%F_%H%M"`

log=/tmp/build-log-$mydate.txt

echo "Start build script"

linux command 1

linux command 2

linux command 3

linux command etc

  1. We're all done with the rc.local that has the build.sh command in it.

# replace with the original and then reboot

echo "restore original rc.local"

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

rm -f /tmp/build.sh

echo "rebooting..."

reboot

EOF1

#

        1. End of /tmp/build.sh creation ###############

View solution in original post

0 Kudos
8 Replies
Chuck8773
Hot Shot
Hot Shot
Jump to solution

Welcome to the Forums!!

I followed Duncan Epping's blog on this topic and it worked perfectly for me. The only hiccup I had was Windows kept wanting to put 0D characters into the file when I saved it. The presence of these characters messes the scripted install up.

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

Charles Killmer, VCP

If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

Charles Killmer, VCP4 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
halibut
Enthusiast
Enthusiast
Jump to solution

I followed a number of posts on this and found the only post scripts that work were the ones that only used "cat" or "echo" otherwise if I used the esxcfg commands or vimsh it doesn't even run them.

I have tried adding --interpreter=/bin/bash to the %post and the script fails completely.

Am I missing something?

Also the adduser statement only adds the user, but ssh either doesn't recognize the user is in the Ssh conf or ecetera...

Chris Halverson

0 Kudos
BenConrad
Expert
Expert
Jump to solution

Best practice is to cat everything into a .sh file and then on first boot you switch rc.local to use that .sh file, then at the end of the .sh file you swap back rc.local so on final boot the server boots normally.

Also, you can't run any commands that use the vmkernel during the kickstart, the vmkerel is not loaded. In v4, the vmkernel is loaded during scripted builds.

  1. Everything between the << EOF1 and EOF1 will be echoed to /tmp/build.sh

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

#!/bin/sh

mydate=`date +"%F_%H%M"`

log=/tmp/build-log-$mydate.txt

echo "Start build script"

linux command 1

linux command 2

linux command 3

linux command etc

  1. We're all done with the rc.local that has the build.sh command in it.

# replace with the original and then reboot

echo "restore original rc.local"

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

rm -f /tmp/build.sh

echo "rebooting..."

reboot

EOF1

#

        1. End of /tmp/build.sh creation ###############

0 Kudos
halibut
Enthusiast
Enthusiast
Jump to solution

That makes complete sense, I had planned on creating all these items in a bash script and running them in a cron job or something but that will work much better. I am going to try it and report back.

Thanks!

Chris

0 Kudos
halibut
Enthusiast
Enthusiast
Jump to solution

Well the solution still doesn't run. It appears nothing in the %post script works. Whether I use a cat or any other command.

I see many solutions around this that work in the post commands so is there something that I am missing?

C

0 Kudos
BenConrad
Expert
Expert
Jump to solution

Did you replace rc.local with the contents of the catted file in the %post section?

0 Kudos
halibut
Enthusiast
Enthusiast
Jump to solution

yes. here is the %post that I run

%packages

@base

@ everything

%post

#Modify DNS Config

cat &gt; /etc/resolv.conf &lt;&lt; EOF

search &lt;removed&gt;

nameserver &lt;removed&gt;

nameserver &lt;removed&gt;

EOF

#Modify NTP Config

cat &gt; /etc/ntp.conf &lt;&lt; EOF

restrict 127.0.0.1

restrict default kod nomodify notrap

server &lt;removed&gt;

driftfile /var/lib/ntp/drift

EOF

cat &gt; /etc/ntp/step-tickers &lt;&lt; EOF

&lt;removed&gt;

EOF

#MOTD Restriction Banners

cat &gt; /etc/restricted_access &lt;&lt; EOF

Logging onto a Restricted Server - UNAUTHORIZED ACCESS PROHIBITED

EOF

echo Banner /etc/restricted_access &gt;&gt; /etc/ssh/sshd_config

cat &gt; /tmp/esxcfg.sh &lt;&lt;EOF1

#!/bin/sh

  1. Configure ESX Server

/sbin/chkconfig --level 345 ntpd on

/sbin/service ntpd start

/sbin/hwclock --systohc

/usr/sbin/esxcfg-vswitch --del-pg="Service Console" vswitch0

/usr/sbin/esxcfg-vswitch --add-pg="Service_Console" vswitch0

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic0 vSwitch0 --pg="Service_Console"

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic2 vSwitch0 --pg="Service_Console"

/usr/sbin/esxcfg-vswitch --add vSwitch1:64

/usr/sbin/esxcfg-vswitch --add-pg="vMotion" vswitch1

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic3 vSwitch1 --pg="vMotion"

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic7 vSwitch1 --pg="vMotion"

/usr/sbin/esxcfg-vswitch --add vSwitch2:128

/usr/sbin/esxcfg-vswitch --add-pg="Prod_v100" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="Prod_v100" --vlan=100

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="Prod_v100" --vlan=100

/usr/sbin/esxcfg-vswitch --add-pg="Prod_v21" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="Prod_v21" --vlan=21

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="Prod_v21" --vlan=21

/usr/sbin/esxcfg-vswitch --add-pg="VMInternal_v4094" vswitch2

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic1 vSwitch2 --pg="VMInternal_v4094" --vlan=4094

/usr/sbin/esxcfg-vswitch --add-pg-uplink vmnic4 vSwitch2 --pg="VMInternal_v4094" --vlan=4094

/usr/sbin/esxcfg-vswitch --link=vmnic0 vSwitch0

/usr/sbin/esxcfg-vswitch --link=vmnic2 vSwitch0

/usr/sbin/esxcfg-vswitch --link=vmnic3 vSwitch1

/usr/sbin/esxcfg-vswitch --link=vmnic7 vSwitch1

/usr/sbin/esxcfg-vswitch --link=vmnic1 vSwitch2

/usr/sbin/esxcfg-vswitch --link=vmnic4 vSwitch2

perl -p -i -e 's/teamPolicy\/maxActive = "."/teamPolicy\/maxActive = "2"/g' /etc/vmware/esx.conf

  1. Create a local user for SSH Access

useradd -p 'removed' -c "New Account Created By Kickstart" ctemp

EOF1

  1. Make esxcfg.sh eXecutable

chmod +x /tmp/esxcfg.sh

  1. Make esxcfg.sh run from rc.local and make rc.local reset itself

cat &gt;&gt; /etc/rc3.d/S30vmwarePostConfig &lt;&lt;EOF

cd /tmp

/tmp/esxcfg.sh

EOF

I tried with the replacing of the rc.local and this is the latest attempt. The S30vmwarepostconfig nor the /tmp/esxcfg.sh ever get created.

0 Kudos
halibut
Enthusiast
Enthusiast
Jump to solution

anyone?

0 Kudos