VMware Cloud Community
paul-bogodynami
Contributor
Contributor

Lamer in need of ks.cfg help.

having issues with a kick start script. 1) the script dont chmod to execute during inital phase. 2) getting "failed to connect:514 Error connecting to hosTd-vmdb service instance" when running --nicteaming-policy..

Please advise and recomend. Thanks in advance

install

cdrom

bootloader --location=mbr

timezone GMT

skipx

install

text

network --device eth0 --bootproto static --ip 1 --netmask 1 --gateway 1 --nameserver 1 --hostname 1 --addvmportgroup=0 --vlanid=0

lang en_UK

langsupport --default en_UK

keyboard uk

mouse none

reboot

firewall --disabled

clearpart --all --initlabel --drives=cciss/c0d0

part /boot --fstype ext3 --size=250 --ondisk=cciss/c0d0 --asprimary

part / --fstype ext3 --size=5120 --grow --maxsize=5120 --ondisk=cciss/c0d0 --asprimary

part swap --size=1600 --grow --maxsize=1600 --ondisk=cciss/c0d0 --asprimary

part /var --fstype ext3 --size=4096 --ondisk=cciss/c0d0

part /opt --fstype ext3 --size=2048 --ondisk=cciss/c0d0

part /tmp --fstype ext3 --size=1024 --ondisk=cciss/c0d0

part /home --fstype ext3 --size=1024 --ondisk=cciss/c0d0

part None --fstype vmkcore --size 110 --ondisk=cciss/c0d0

part None --fstype vmfs3 --size 1 --grow --ondisk=cciss/c0d0

vmaccepteula

vmlicense --mode=server mailto:server=27000@1-- --edition=Full

%packages

%post

cat > /etc/rc.d/rc3.d/S99verylast << EOF

#Configure Firewall and startup services

echo " Configuring firewall"

chkconfig ntpd on

chkconfig snmpd on

esxcfg-firewall -e ntpClient

esxcfg-firewall -e snmpd

esxcfg-firewall -e sshClient

esxcfg-firewall -e CIMSLP

esxcfg-firewall -e VCB

esxcfg-firewall -e swISCSIClient

esxcfg-firewall -e CIMHttpsServer

esxcfg-firewall -e vpxHeartbeats

esxcfg-firewall -e LicenseClient

esxcfg-firewall -e sshServer

esxcfg-firewall -e updateManager

#Configure DNS resolver

echo "search 1 >> /etc/resolv.conf

echo "nameserver 1" >> /etc/resolv.conf

echo "nameserver 1" >> /etc/resolv.conf

#Configure NTP

echo " Configuring NTP"

echo "restrict kod nomodify notrap noquery nopeer" > /etc/ntp.conf

echo "restrict 127.0.0.1" >> /etc/ntp.conf

echo "server 172.1" >> /etc/ntp.conf

echo "server 172.1" >> /etc/ntp.conf

echo "driftfile /var/lib/ntp/drift" >> /etc/ntp.conf

service ntpd start

hwclock --systohc

echo " Configuring UKVEN SNMP"

#Configure SNMP

echo "defcommunity 1" >> /usr/share/snmp/snmp.conf

echo "rocommunity 1" >> /usr/share/snmp/snmpd.conf

#Configure iSCSI CHAP

echo "OutgoingUsername=1" >> /etc/vmkiscsi.conf

echo "OutgoingPassword=1" >> /etc/vmkiscsi.conf

echo "DiscoveryAddress=1:3260" >> /etc/vmkiscsi.conf

#Configure log compression

echo " Configuring log compression"

perl -p -i -e 's/nocompress/compress/g' /etc/logrotate.d/vmkernel

perl -p -i -e 's/nocompress/compress/g' /etc/logrotate.d/vmksummary

perl -p -i -e 's/#compress/compress/g' /etc/logrotate.conf

#Configure secure permissions on critical files

echo " Configuring file permissions"

chmod 700 /etc/snmp/snmpd.conf

chmod 600 /etc/grub.conf

#Configure hosts files to prevent DNS failure

echo " Configuring hosts file"

echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts

echo "1" >> /etc/hosts

echo "2" >> /etc/hosts

echo "3" >> /etc/hosts

echo "4" >> /etc/hosts

echo "5" >> /etc/hosts

echo "6" >> /etc/hosts

echo "7" >> /etc/hosts

#Configure ESX Networking

echo " Configuring networking"

esxcfg-vswitch -a vSwitch2:64

esxcfg-vswitch -a vSwitch1:64

esxcfg-vswitch -a vSwitch3:64

esxcfg-vswitch -L vmnic0 vSwitch0

esxcfg-vswitch -L vmnic5 vSwitch2

esxcfg-vswitch -L vmnic4 vSwitch1

esxcfg-vswitch -m 9000 vSwitch1

esxcfg-vswitch -A "VLAN16" vSwitch0

esxcfg-vswitch -A "VLAN11" vSwitch0

esxcfg-vswitch -A "VLAN13" vSwitch0

esxcfg-vswitch -A "VLAN17" vSwitch0

esxcfg-vswitch -A "VLAN10" vSwitch0

esxcfg-vswitch -A "VLAN410" vSwitch0

esxcfg-vswitch -A "VLAN12" vSwitch0

esxcfg-vswitch -A "VLAN15" vSwitch0

esxcfg-vswitch -A "VLAN2-INTERNET" vSwitch2

esxcfg-vswitch -A "VLAN983-DMZ" vSwitch2

esxcfg-vswitch -A "VLAN993-DMZ" vSwitch2

esxcfg-vswitch -A "IPSAN-GUEST" vSwitch1

esxcfg-vswitch -A "IPSAN" vSwitch1

esxcfg-vswitch -A "Service Console 2" vSwitch1

esxcfg-vswitch -A "INTERNAL" vSwitch3

esxcfg-vswitch -p "VLAN16" -v 16 vSwitch0

esxcfg-vswitch -p "VLAN11" -v 11 vSwitch0

esxcfg-vswitch -p "VLAN13" -v 13 vSwitch0

esxcfg-vswitch -p "VLAN17" -v 17 vSwitch0

esxcfg-vswitch -p "VLAN10" -v 10 vSwitch0

esxcfg-vswitch -p "VLAN410" -v 410 vSwitch0

esxcfg-vswitch -p "VLAN12" -v 12 vSwitch0

esxcfg-vswitch -p "VLAN15" -v 15 vSwitch0

esxcfg-vswitch -p "VLAN2-INTERNET" -v 2 vSwitch2

esxcfg-vswitch -p "VLAN983-DMZ" -v 983 vSwitch2

esxcfg-vswitch -p "VLAN993-DMZ" -v 993 vSwitch2

echo " Configuring NIC duplex/speed"

#Configure NIC duplex/speed settings

esxcfg-nics -s 100 -d full vmnic0

esxcfg-nics -s 100 -d full vmnic1

esxcfg-nics -s 100 -d full vmnic2

esxcfg-nics -s 100 -d full vmnic3

esxcfg-nics -s 100 -d full vmnic4

esxcfg-nics -s 100 -d full vmnic5

echo " Configuring NIC teaming policy"

sleep 50

#Configure Teaming Policy

vmware-vim-cmd hostsvc/net/refresh

vmware-vim-cmd hostsvc/net/vswitch_setpolicy --nicteaming-policy loadbalance_ip vSwitch0

vmware-vim-cmd hostsvc/net/vswitch_setpolicy --nicteaming-policy loadbalance_ip vSwitch2

vmware-vim-cmd hostsvc/net/vswitch_setpolicy --nicteaming-policy loadbalance_ip vSwitch1

vmware-vim-cmd hostsvc/net/vswitch_setpolicy --nicorderpolicy-active vmnic3,vmnic2 vSwitch0

vmware-vim-cmd hostsvc/net/vswitch_setpolicy --nicorderpolicy-active vmnic1 vSwitch1

#Configure VMotion

#service mgmt-vmware restart

sleep 30

echo " Configuring VMotion"

esxcfg-vswif -a -i 1 -n 1 -p "Service Console 2" vswif1

esxcfg-vmknic -a -i 1 -n 1 -m 9000 IPSAN

esxcfg-vswif -E

vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0

echo " Configuring default VMkernel gateway"

esxcfg-route -a default 1

sleep 30

echo " Configuring hostsvc file"

cat > /etc/vmware/hostd/hostsvc.xml << HOSTSVC

<ConfigRoot>

<mode>normal</mode>

<service>

<ntpd>automatic</ntpd>

<sshd>automatic</sshd>

</service>

<vmotion>

<nic>IPSAN</nic>

</vmotion>

</ConfigRoot>

HOSTSVC

perl -i -pe 'chomp if eof' /etc/vmware/hostd/hostsvc.xml

echo " Enabling VMotion"

esxcfg-advcfg -s 1 /Migrate/Enabled

#service mgmt-vmware restart

sleep 20

echo " Configuring iSCSI Connections"

#Configure iSCSI

esxcfg-swiscsi -e

vmkiscsi-tool -D -a 1 vmhba32

esxcfg-rescan vmhba32

echo " Making sure the script runs only once"

mv /etc/rc.d/rc3.d/S99verylast /etc/rc.d/rc3.d/xS99verylast

EOF

/bin/chmod +x /etc/rc.d/rc3.d/S99verylast

0 Kudos
9 Replies
max_inglis
Enthusiast
Enthusiast

You may want to modify your post to remove direct references to your domain - lots of people consider that a security risk.

http://ITangst.blogspot.com
0 Kudos
Dave_Mishchenko
Immortal
Immortal

Which version of ESX are you using?

0 Kudos
paul-bogodynami
Contributor
Contributor

Thanks, long day, thourght I got them all.

0 Kudos
paul-bogodynami
Contributor
Contributor

35u2

0 Kudos
Dave_Mishchenko
Immortal
Immortal

This discussion has been moved to the VI: ESX 3.5 forum.

Dave Mishchenko

VMware Communities User Moderator

0 Kudos
stvkpln
Virtuoso
Virtuoso

On the failed to connect portion, that's a fairly easy one... It takes the host services a little longer to initialize.. Before you start running anything involving vmware-vim-cmd, you need to put a sleep statement in for anything between 20-60 seconds.. In ours, we use 40 and it works flawlessly.

-Steve
0 Kudos
paul-bogodynami
Contributor
Contributor

I have added sleep 50 to the above.

any ideas why chmod isnt doing its job?

0 Kudos
lldmka
Enthusiast
Enthusiast

I use the following and it works well:

cat > /tmp/esxcfg.sh << EOF

code

EOF

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

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

/bin/chmod +x /tmp/esxcfg.sh

cd /tmp

./esxcfg.sh > /root/post_install.log

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

EOF1

0 Kudos
james_charter
Contributor
Contributor

Found this post really useful for the sleep reference when using vmware-vim-cmd. I was having a tough time figuring out how the nic teaming options weren't running when everything else was.

Thanks lldmka!

--late to the party again!

0 Kudos