VMware Cloud Community
slayer199
Contributor
Contributor

Scripted Install of ESXi 4.1 using the UDA

I've been able to accomplish some basic tasks using the UDA to deploy multiple ESXi 4.1 hosts. Assigning the hostname, IP, vMotion IP/pg/vSwitch, NTP, etc.

I'm stuck on a couple issues, but the one that is really bugging me is that I can't get it to assign the DNS servers via the ks.cfg. I m able to successfully run the vim-cmd in tech support mode after the host comes up, but it doesn't work from the automated install:

Here's the ks.cfg:


# VMware ESXi4.1 template Kickstart file

# root Password
rootpw secret

# Installation Method
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]

# Use first detected disk:
autopart --firstdisk --overwritevmfs
reboot

# Assigning SC IP
network --device=vmnic0 --bootproto=static --ip=[IPADDR] --netmask=255.255.255.0 --gateway=10.66.100.1 --nameserver=10.66.100.100 --hostname=[HOSTNAME].csg.adp.loc --addvmportgroup=false

# VMware Specific Commands
vmaccepteula

%firstboot --unsupported --interpreter=busybox

#enable TechSupportModes
vim-cmd hostsvc/enable_local_tsm
vim-cmd hostsvc/start_local_tsm
vim-cmd hostsvc/net/refresh 

#Add new vSwitch for vMotion
esxcfg-vswitch -a vSwitch1

#Add pNIC vmnic1 to vSwitch1
esxcfg-vswitch -L vmnic1 vSwitch1

#Add vMotion Portgroup to vSwitch1
esxcfg-vswitch -A VMkernel vSwitch1

#Assign ip address to vMotion vmk1
esxcfg-vmknic -a -i [VMOTIONIP] -n 255.255.254.0 -p VMkernel

#Assign VLAN to vMotion PortGroup
esxcfg-vswitch -v 0 -p VMkernel vSwitch1

sleep 5

#Enable vMotion to vmk1
vim-cmd hostsvc/vmotion/vnic_set vmk1


# NTP time config
echo restrict default kod nomodify notrap noquerynopeer > /etc/ntp.conf
echo restrict 127.0.0.1 >> /etc/ntp.conf
echo server 10.66.100.100 >> /etc/ntp.conf
echo server 10.66.100.101 >> /etc/ntp.conf
echo driftfile /var/lib/ntp/drift >> /etc/ntp.conf
/sbin/chkconfig –-level 345 ntpd on
/etc/init.d/ntpd stop
/etc/init.d/ntpd start

#Set DNS
vim-cmd hostsvc/net/dns_set –-ip-addresses=10.66.100.100,10.66.100.101
vim-cmd hostsvc/net/refresh 

#One final reboot
reboot

I've moved the #Set DNS string all over to no avail. The only other thing I'd like to do (but it's minor and I haven't seen anyone with a lot of luck doing it) is installing the HP-CIM offline agents and updating the hosts file.

Reply
0 Kudos
7 Replies
Troy_Clavell
Immortal
Immortal

why not just set the DNS servers in this section?

# Assigning SC IP
network --device=vmnic0 --bootproto=static --ip=[IPADDR] --netmask=255.255.255.0 --gateway=10.66.100.1 --nameserver=10.66.100.100 --hostname=[HOSTNAME].csg.adp.loc --addvmportgroup=false

something like

--nameserver="10.66.100.100,10.66.100.101"

but you may be having problems because you're missing the open and close quotes.

Reply
0 Kudos
slayer199
Contributor
Contributor

I just tried it, no joy.

When I add the server to vCenter, Configuration-DNS and Routing; the DNS servers are empty. If I run the command manually, it populates.

Reply
0 Kudos
Troy_Clavell
Immortal
Immortal

I think since your syntax is wrong by not using the open and closed quotes, the %firstboot is creating a blank entry because of the error. I would remove this line

#Set DNS
vim-cmd hostsvc/net/dns_set –-ip-addresses=10.66.100.100,10.66.100.101vim-cmd hostsvc/net/refresh

and just use the

--nameserver="10.66.100.100,10.66.100.101"

and see if that works. Or remove the --nameserver entry and use the open in close quotes when you specify your DNS entries in your %firstboot.

Reply
0 Kudos
slayer199
Contributor
Contributor

I've removed the #Set DNS portion and tried the --nameserver line (in quotes) using both DNS servers --to no avail.

I also tried the #set DNS portion in quotes, no joy.

If I run the vim-cmd /hostsvc/net/dns_set command from TSM, it successfully adds the DNS servers though the other ks.cfg methods don't work for some reason.

Reply
0 Kudos
Troy_Clavell
Immortal
Immortal

I wish I had a better answer, than it should work. This is how we do ours, meaning the --nameserver. I've added a snip of our ks.cfg, but we don't do as much in ours as you. Most of our post install is done with PowerCLI

# basic networking
network --bootproto=static --device=vmnic0 --ip=10.66.226.35 --netmask=255.255.255.0 --gateway=10.66.226.1 --hostname=esxi.local.domain --vlanid=0 --nameserver="10.64.1.178,10.4.1.179" --addvmportgroup=0
 
# reboot at the end
reboot

%firstboot --unsupported --interpreter=busybox

#Rename local Datastore
vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)-local"

#enable SSH TechSupportMode
vim-cmd hostsvc/enable_remote_tsm
vim-cmd hostsvc/start_remote_tsm

#disable modules
esxcfg-module -d nfsclient

slayer199
Contributor
Contributor

I still have one last sticking point in addition to the DNS issue (though that one is really bugging me). Setting up HP-CIM offline agent installation. Not that big of a deal since it can be done via script on our Tools server with vCLI.

BTW- I forgot to rename my local datastore in my kickstart so your last post really helped.

Reply
0 Kudos
slayer199
Contributor
Contributor

After a week of beating my head against a wall trying to figure out why the vim-cmd didn't work, I found a simple solution. There's more than one way to skin a cat. While it bugs me that I can't figure out why the vim-cmd didn't work, this solution does work.

 #DNS config
echo nameserver 10.100.0.100 >> /etc/resolv.conf
echo nameserver 10.100.0.101 >> /etc/resolv.conf 

Reply
0 Kudos