VMware Cloud Community
4jchaumont
Contributor
Contributor

Deploy ESX4.1 & ESXi4.1 with Kickstart and UDA and vlans

Hello,

I have a problem with my scripts in UDA. I want to rename the datastore in the firstboot after the installation of ESX or ESXi (4.1)

Here my scripts for kickstart :

ESXi 4.1 u1 :

########################## BEGIN ks.cfg ##################################

# VMware ESXi 4.1 Kickstart file

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

# root Password
rootpw exemple

# Timezone
timezone Europe/Paris

# Keyboard
keyboard French

# Clear Partitions
autopart --firstdisk --overwritevmfs

#IP configuration
network --device=vmnic0 --bootproto=static --ip=[IPADDR] --netmask=[SUBNET] --gateway=[GW] --nameserver=[DNS] --hostname=[HOSTNAME]

# Reboot after install ?
reboot

# VMware Specific Commands
vmaccepteula

%firstboot --unsupported --interpreter=busybox
vim-cmd hostsvc/datastore/rename datastore1 “$(hostname -s)-local-storage”


########################## END ks.cfg ##################################

ESX 4.1:

########################## BEGIN ks.cfg ##################################

# VMware ESX4 Kickstart file

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

# root Password
rootpw exemple

# BootLoader ( The user has to use grub by default )
bootloader --location=mbr

# Timezone
timezone Europe/Paris

# Network install type
network --device=vmnic0 --bootproto=static --ip=[IPADDR] --netmask=[SUBNET] --gateway=[GW] --nameserver=[DNS] --hostname=[HOSTNAME]

# Keyboard
keyboard fr-latin1

# Reboot after install ?
reboot

# Firewall settings
firewall --disabled

# Clear Partitions
clearpart --firstdisk --overwritevmfs

# Either choose autopartitioning
autopart --firstdisk

# VMware Specific Commands
vmaccepteula

%firstboot --unsupported --interpreter=busybox
vim-cmd hostsvc/datastore/rename datastore1 “$(hostname -s)-local-storage”

########################## END ks.cfg ##################################

All seems fine (keyboard, hostname, ip, partitions, ) except when i want to rename the datastore. i don't see any errors but it doesn't work, the name is still datastore1 after the deployment of the ESX or ESXi.

Did i made a mistake in my ks.cfg file ? I have search all over the net for a solution but each time the command line is the same.

Can you help me with those 2 scripts ?

Thank you very much

Ce message a été modifié par: 4jchaumont

Reply
0 Kudos
2 Replies
KenGould
Contributor
Contributor

Your problem is not that your datastore rename command isn't running I suspect, but that the hostname variable has no value at the time it is executed.

Remember that it is being executed after the reboot of the host, so the variable values from the pxelinux environment are now null and void.

What you need to do as part of the %pre part of your ks script is to echo the values into the esx install log like this:

%pre --interpreter=busybox

ESXI_INSTALL_LOG=/var/log/esxi_install.log

echo "KENS_CUSTOM_VARIABLE-HOSTNAME ${HOSTNAME}" >> ${ESXI_INSTALL_LOG}

Then on firstboot, you need to retrieve this value from the esx install log and pass it to the vim-cmd like this

%firstboot --unsupported --interpreter=busybox
#extract custom variables in ESXi install log
HOSTNAME=$(grep "^KENS_CUSTOM_VARIABLE-HOSTNAME" /var/log/esxi_install.log | awk '{print $2}')
vim-cmd hostsvc/datastore/rename datastore1 "${HOSTNAME}"
Credit to Ghetto of www.virtuallyghetto.com for the guidance...I simply modified for my own purposes.
I know the above will work with ESXi4. However, I believe firstboot was deprecated on ESX4 (not sure if there is an alternative to that available on ESX4, but would love to know if someone else does)
Reply
0 Kudos
4jchaumont
Contributor
Contributor

Thank you KenGould, i will try your solution as soon as i have succeeded to configure my UDA in production.

I have forgot one little thing when i have made all my deployment test, the infrastructure in wich i have to deploy the esxi/esx has vlans. And the problem is that i can't modify the native vlan (reason : security), so when i boot in pxe mode, i can't find the dhcp.

My blades are dell's one, so i can tag the vlan for the pxe mode. The server can find the dhcp, boot in pxe with UDA, but when the installation needs the ks.cfg file, the server is no longer in pxe mode, so the vlan is not tagged anymore and the server can't retrieve an ip in the dhcp.

Now i try to find a way to make a copy of the ks file in the local drive during the %pre in the ks file, but i don't know how to modify the pxe option to target the copied ks.cfg in the local hard drive (ks=hd:??? i don't know the path and the mounted point for the hard drive, hd0, sd, etc...)

Another solution is to put all my ks.cfg in an iso and plug the iso in the virtual cd-rom (the one we can connect with iDRAC), but ks=cdrom don't work, and i don't find the good link to target the virtual cd-rom.

The third solution i study is the IPAPPEND option, but i don't find any good exemples to configure this option in UDA.

If anyone has another idea to solve this problem or a hint to make one of my solution works, it will be great.

Reply
0 Kudos