VMware Cloud Community
Michelle_Laveri
Virtuoso
Virtuoso

Scripted Installations Thread

It's occoured to me that currently peoples "kickstart" questions & answers are dotted all over the place on various other threads/blogs. Beyond that there seems to be innumberable resources online especially on redhat.com.

Most of my work with kickstart has been with the UDA, although I have done some work building custom ESX CDs, and at some stage I must return to the topic of putting ESX on a memory stick - which has worked for others, but I've never made work personally.

I wondered if it would be useful to have like a "master" kickstart thread were people post their findings or questions in one place. Perhaps like a sticky FAQ?

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
206 Replies
virtech
Expert
Expert

Sounds like a good idea to me

Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

OK, well lets seed this thread...

Every day I plan to add a new reply to this message... here's my first...

How would I enable a message to be sent at the end of kickstart install to tell me that it has finished...?[/b]

1. enable the Windows Messenger Service on your management station

add this to the end of the kickstart post at runs when the esx host first boots:

cp /etc/hosts /etc/hosts.bak

echo 192.168.3.198 mf1 >> /etc/hosts

esxcfg-firewall -e smbClient

echo ESX Host: esx4.vi3book.com has completed the build process > /tmp/msg.txt

smbclient -I 192.168.3.198 -M mf1 < /tmp/msg.txt

esxcfg-firewall -d smbClient

rm /tmp/msg.txt -f -r

mv -f /etc/hosts.bak /etc/hosts

where 192.168.3.198 is the destination, and MF1 is the netBIO name of Windows XP Professional/W2K3 TS Server... in my case my citrix box...

Regards

Mike

Message was edited by:

Mike_Laverick

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
virtech
Expert
Expert

Hey thats cool, going to try that.

I have a question:

How do I script an installation to leave a VMFS-2 partition intact and upgrade it to VMFS-3 ?[/b]

Reply
0 Kudos
virtech
Expert
Expert

Mike do you know if its possible to send email based notifications alerts out?

I'm guessing there is no smtp mail client installed on the ESX3 server ?

Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

How do I script an installation to leave a VMFS-2

partition intact and upgrade it to VMFS-3 ?[/b]

Not tested:

First you would need an upgrade script - like this:

\# Auto-Generated Scripted Install Configuration file.

\# This file is used for VMware ESX Server Scripted Install Deployment

\# Regional Settings

keyboard us

lang en_US

langsupport --default en_US

timezone America/New_York

\# Installation Method

url --url http://192.168.3.150/esx/esx301/

\# root Password

\# Authconfig

\# BootLoader ( The user has to use grub by default )

bootloader --location=mbr --driveorder=cciss/c0d0

\# Timezone

\# X windowing System

skipx

\# Install or Upgrade

upgrade

\# Text Mode

text

\# Network install type

\# Language

\# Langauge Support

\# Keyboard

\# Mouse

mouse none

\# Reboot after install ?

reboot

\# Firewall settings

firewall --disabled

\# Clear Partitions

\# Partitioning

\# VMware Specific Commands

vmaccepteula

%packages

@base

%post

%vmlicense_text

Then underneath %post we have we would script the unloading of the vmfs2/3 drivers, and a load of the auxilary driver in upgrade mode. We would use vmkfstools to do the upgrade - and then load the drivers up. Incidentally, I would find this very scarey - but I guess if its a local VMFS volume you have less worries...

\# Your postinstall script goes here!

cat > /tmp/esxcfg.sh <<EOF1
#!/bin/sh
\# Configure ESX Server

\# Converting VMFS2 to VMFS3
vmkload_mod -u vmfs2
vmkload_mod -u vmfs3
vmkload_mod fsaux fsauxFunction=upgrade
vmkfstools -T /vmfs/volumes/local -x zeroedthick < answeryes.txt
vmkload_mod -u fsaux
vmkload_mod vmfs2
vmkload_mod vmfs3
EOF1

\# Make esxcfg.sh eXcutable
chmod +x /tmp/esxcfg.sh

\# Backup original rc.local file
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

\# Make esxcfg.sh run from rc.local and make rc.local reset itself
cat >> /etc/rc.d/rc.local <<EOF

cd /tmp

/tmp/esxcfg.sh

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

EOF

Regards

Mike

Message was edited by:

Forum poster here is being really wierd - should not be <> but just < but when I got to edit the > away - it doesn't show! Jive software!

null

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

I'm guessing there is no smtp mail client installed

on the ESX3 server ?

Well, if not perhaps we could install from the network an command-line smtp tool... install it silently with rpm... open smpt/tcp 25 - send the message... uninstall the RPM, close of the ports...

Anyone want to take a look at doing this...?

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
Jae_Ellers
Virtuoso
Virtuoso

HP SIM Agent installs

http://www.vmware.com/community/thread.jspa?threadID=86983&tstart=45

-=-=-=-=-=-=-=-=-=-=-=-=-=-=- http://blog.mr-vm.com http://www.vmprofessional.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

I use the UDA to do my deployments which acts as the central source for my hardware agent software and patches...

This is the kickstart script I use to install the HP SIM

service portmap start && service nfs start

esxcfg-firewall -e nfsClient

mkdir /tmp/udasource

mount 192.168.3.150:/var/public/smbmount/DISK2 /tmp/udasource

\# Copy down the HP SIM to /tmp

\# Execute the Installer

mkdir /tmp/hpmgmt/770 -p

cp /tmp/udasource/hpmgmt/770/* /tmp/hpmgmt/770

cd /tmp/hpmgmt/770

./installvm770.sh –silent –inputfile hpmgmt.conf

\# Clean up after using NFS on the UDA

\# Unmount udasource, remove mounting point, stop services, close firewall

umount /tmp/udasource

rmdir /tmp/udasource

service nfs stop && service portmap stop

esxcfg-firewall -d nfsClient

Regards

Mike

Message was edited by:

Mike_Laverick - removed the dangerous rm -f -r with a rmdir... Smiley Happy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Q. How do I create a local VMFS volume as part of a scripted installation:[/b]

A. Firstly, you need to create the VMFS partition using the part option in the kickstart file like so

clearpart –all –drives=cciss/c0d0 –initlabel

part /boot –fstype ext3 –size 250 –ondisk=cciss/c0d0

part swap –size 1600 –ondisk=cciss/c0d0

part / –fstype ext3 –size 5120 –ondisk=cciss/c0d0

part /var –fstype ext3 –size 2048 –ondisk=cciss/c0d0

part /tmp –fstype ext3 –size 2048 –ondisk=cciss/c0d0

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

part /home –fstype ext3 –size 2048 –ondisk=cciss/c0d0

part None –fstype vmkcore –size 100 –ondisk=cciss/c0d0

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

Note:

/vmfs is required in kickstart to be successful. Grow indicates the vmfs partition should use the remainder of the disk. Despite being the last partition mentioned, the anaconda script actually makes the vmkcore the 10th partition with the VMFS being the 9th partition... Anaconda appear to only create the VMFS partition - its doesn't format the partition...

So in the post script section use vmkfstools for format the partition

vmkfstools -C vmfs3 -S esx4-localstorage vmhba0:0:0:9

If you are unsure of the what the vmhba syntax should be - use esxcfg-vmhbadevs to find the Linux /dev/ identity to the volume - and fdisk /dev/sda or whatever to find out the partition number - look for the fb type is the hex which indicates a VMFS volume...

Regards

Mike

Message was edited by:

Mike_Laverick

Corrected a slight mistake - should be None for the "mount point" not /vmfs as I had earlier...

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Q. How do I change the NIC assigned to the Service Console?[/b]A. In the %post script section use something like this:

esxcfg-vswitch -U vmnic0 vSwitch0

esxcfg-vswitch -L vmnic5 vSwitch0

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
wila
Immortal
Immortal

If you can use perl, then you could use this script:

http://www.vmware.com/community/click.jspa?searchID=3062532&messageID=536286

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Q. I have put esxcfg- commands in the %post section - but they don't seem to run - Why?[/b]

A. The %post section is run by anaconda immediately after the file copy process ends. At this stage a linux kernel is loaded. The esxcfg commands are vmkernel commands, and as such the vmkernel must be loaded for them to work. To deal with this situation it is common to create/modify a script that runs on first-boot. If your a windows guy, you could see it as tagging a referrence to the end of autoexec.bat or putting a script in the start-up directory. There two ways of getting this script to execute. One is to create a start-up script s101post-config for example - or to modify rc.local (the last script to be executed in the boot process). My personal preference is for rc.local.

This is pretty much "standard" template for making esxcfg- commands work

\# Your postinstall script goes here!

cat > /tmp/esxcfg.sh <<EOF1
#!/bin/sh
\# Configure ESX Server

PUT YOUR ESXCFG commands & other here....

EOF1

\# Make esxcfg.sh eXcutable
chmod +x /tmp/esxcfg.sh

\# Backup original rc.local file
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

\# Make esxcfg.sh run from rc.local and make rc.local reset itself
cat >> /etc/rc.d/rc.local <<EOF

cd /tmp

/tmp/esxcfg.sh

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

EOF

This creates a script file called esxcfg.sh... which is then called by rc.local. Once esxcfg.sh has been execute, rc.local is reset to make sure the script doesn't run again at the next boot...

Regards

Mike

Message was edited by:

Mike_Laverick

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
gogogo5
Hot Shot
Hot Shot

This is a useful PDF explaining how Linux enumerates NICs during device discovery. I found this useful in understanduing why, during my scripted install, the SC NIC didnt bind to vmnic0, which was the first onboard NIC I wanted to assign.

http://linux.dell.com/files/whitepapers/nic-enum-whitepaper-v3.pdf

Reply
0 Kudos
virtech
Expert
Expert

Does anyone know if you can use a AD group to authenticate with in ESX3 ? Normally you have to create a user on the ESX3 server that matches a user in AD.

Reply
0 Kudos
dinny
Expert
Expert

Hiya,

I believe it is possible - see:

http://www.vmware-tsx.com/download.php?asset_id=37

But it doesn't look particularly straight forward... Smiley Wink

Dinny

Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Hiya,

I believe it is possible - see:

http://www.vmware-tsx.com/download.php?asset_id=37

But it doesn't look particularly straight forward...

Smiley Wink

Dinny

Yup, this WinBind thing was pretty cool at the TSX... I tried following the PPT from Yvo presentation... but didn't have much success... we were promised a whitepaper - but nothing has surfaced yet...

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
virtech
Expert
Expert

Cheers Dinny and Mike

Reply
0 Kudos
dinny
Expert
Expert

Hiya,

If anyone is interested, this is a script that I run at the end of my automated ESX build to send me an email letting me know the build is complete.

It just needs ip connectivity to a server on the network that will relay SMTP messages.

Dinny

Script contents are as follows:

#!/usr/bin/perl -w

\# Script written by Dave Pearson and Dinny Davies 25/06/2007

\# It sends an email from an ESX server at the end of the build process.

\# It just needs IP connectivity to an SMTP server elsewhere on the network

\# e.g. smtpserver.mydomain.co.uk

\# temporarily enable firewall rule to allow access to smtp

$cmdFirewallOn = "esxcfg-firewall -o 25,tcp,out,SMTP";

system($cmdFirewallOn);

use Net::SMTP;

$machine=`uname -n`;

$smtp = Net::SMTP->new("smtpserver.mydomain.co.uk");

print "smtp=$smtp\n";

$smtp->mail("esxbuild\@mydomain.co.uk");

$smtp->to("dinny.davies\@mydomain.co.uk");

$smtp->data();

$smtp->datasend("To: dinny.davies\@mydomain.co.uk\n");

\# $smtp->datasend("To: anyone.else\@lmydomain.co.uk\n");

$smtp->datasend("Subject: Build complete for ESX Server $machine\n");

$smtp->datasend("\n");

$smtp->datasend("$machine \nis now built....\n");

$smtp->dataend();

$smtp->quit;

\# re-apply firewall rule to block SMTP

$cmdFirewallOn = "esxcfg-firewall -c 25,tcp,out,SMTP";

system($cmdFirewallOn);

Reply
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Q. Why doesn't my over the network installations work?

A. There reasons could be more than could be listed here - but lets say you have exhausted the usual suspects like rights, permission, IP settings and so on. You might find this link about network problems and anaconda more useful...

Link:

http://fedoraproject.org/wiki/AnacondaNetworkIssues

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos