Monday, September 17, 2012

vSphere 5.1 ESXi Unattended script building


So I'm slowing working my way through building an automated script for a project I'm on. I had some issues a while ago with this process as every time I would specify a ks.cfg on a USB, it would give me an error on initializing a partion. I still to this day don't know what the issue was. I posted a question on the VMware community boards, but no one ever solved.

Well, the good news is, I've at least passed that point and am working my way through. As I do, I'll update progress on this post. By the end, it should show a running log of what it took to get to the end script, along with said script.

So, I'll start with the other sources I'm pulling info from:


Duncan Epping's Yellow Bricks post about an install script. Great starting point.




William Lam's VirtualGhetto posts about kickstart scripting and esxcli


Official docs

So the offical docs document how to start using the custom script that's included on the stock installation media. Here's how:

1.      Boot to stock installation

2.      When presented yellow bar and the option to, press SHIFT+O to get the boot prompt.

3.      This will give you a prompt like the following ">runweasel" with a cursor flashing at the end.


4.      Simply put a space, and add "ks=file://etc/vmware/weasel/ks.cfg " so the whole thing looks like this:

 

5.      It will chug away for awhile and finally let you know that it will reboot in Eval Mode (even if you specify a license). 
 

So, that gives us the stock ks.cfg on the disc.  Now, there’s a whole mess of places you can use your own ks.cfg from.  Here are the boot options to use them all:


Also, if you want to use a USB, you will need to format it with FAT32.  I think this might have been my initial issue.  Plus, I formatted it with a Linux box (CentOS 6.3 to be specific) and I followed these directions:


Basic script looks like this:

# Accept the VMware End User License Agreement

vmaccepteula

# Set the root password for the DCUI and ESXi Shell

rootpw --iscrypted <password hash>

# Install on the first local disk available on machine

install --firstdisk --overwritevmfs

# Set the network to DHCP on the first network adapater, use the specified hostname and do not create a portgroup for the VMs

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

# reboots the host after the scripted installation is completed

Reboot

 

Now, you see the “rootpw –iscrypted” there with a place for a hash.  Download OpenSSL-Win32 from here:


Once you have that installed, open the command prompt and go to the openssl-win32 folder (for me c:\openssl-win32\bin), and type the following:

Openssl passwd <password you’d like encrypted>

Copy what comes out of there into your ks.cfg.
 
That’s what I have so far.  As I said, it’s a work in progress, and I’m going to try to keep this as a living post. 

No comments:

Post a Comment