Project

General

Profile

Actions

VMware ESXi » History » Revision 15

« Previous | Revision 15/23 (diff) | Next »
Corey Osman, 12/27/2011 10:59 PM


How to Provision a VMware ESXi server using foreman

Although puppet will not run under ESX server we can still use foreman to kickstart the server using PXE.

Summary of what you need to do:
  1. Copy iso contents of ESXi to your media directory
  2. Copy the esx boot files to your tftp directory
  3. Create a ESX Installation Medium in Foreman
  4. Create a ESX operating system in foreman
  5. Create a ESX partition table (optional) template
  6. Create a ESX kickstart template in foreman
  7. Create a ESX pxe or gpxe template for ESX in foreman

Copy iso contents of ESXi to your media directory (example only)
mkdir /mnt/iso1
mkdir -p /var/www/html/repos/vmware/esxi4.1/  
mount -o loop esxi-iso-file.iso /mnt/iso1  (example for RHEL based distros)
rsync -avz /mnt/iso1/ /var/www/html/repos/vmware/esxi4.1/

Copy the esx boot files to your tftp directory (must have all of these)
cp /var/www/html/repos/vmware/esxi4.1/mboot.c32 /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/vmkboot.gz /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/vmkernel.gz /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/sys.vgz /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/cim.vgz /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/ienviron.vgz /var/lib/tftpboot/boot/vmware/
cp /var/www/html/repos/vmware/esxi4.1/install.vgz /var/lib/tftpboot/boot/vmware/

Create the installation medium based on where you put your esx4.1 iso contents
  1. Create new medium
  2. vmware
  3. path: http://192.168.1.88/repos/vmware/esxi$version/ (example only)
  4. OS: ESXi4.1 (can define later after making operating system)

Create a ESX operating system in foreman (Example only)
  1. More-->Operating Systems-->New
  2. Name: ESXi
  3. Major: 4
  4. Minor 1
  5. OS Family: Redhat (there is no vmware yet)
  6. Arch: x86_64
  7. Choose any partition tables if you defined any (can do later)
  8. Choose the vmware installation media (can do later)
  9. Name: esxi4.1 (name whatever you need to)
  10. Assign the template to the ESXi operating system that you defined earlier
  11. Layout: (Something like the following)
    part '/boot'  --fstype=ext3 --size=1100  --ondisk=mpx.vmhba0:C0:T0:L0
    part 'none'  --fstype=vmkcore --size=110  --ondisk=mpx.vmhba0:C0:T0:L0
    part 'datastore1'  --fstype=vmfs3 --size=9004 --grow  --ondisk=mpx.vmhba0:C0:T0:L0
    virtualdisk 'esxconsole' --size=8004 --onvmfs='datastore1'
    
    part 'swap'  --fstype=swap --size=1000 --onvirtualdisk='esxconsole'
    part '/var/log'  --fstype=ext3 --size=2000 --onvirtualdisk='esxconsole'
    part '/'  --fstype=ext3 --size=5000 --grow --onvirtualdisk='esxconsole'
    

Create a Partition table in Foreman (optional)

Create a ESX kickstart template in foreman
  1. More-->provisioning Templates-->new
  2. Type: provision
  3. Name: esxi
  4. Use something like the following for the template:
    accepteula
    
    # Canonical drive names:
    #clearpart --drives=mpx.vmhba0:C0:T0:L0
    # Uncomment to use first detected disk:
    #clearpart --firstdisk
    
    # Uncomment the esxlocation line and comment out the clearpart
    # and physical partitions to do a non-destructive reinstall.
    #esxlocation --uuid=881475a6-700a-4b33-aa24-048909df6c14
    install url <%25= @mediapath %25>
    
    rootpw --iscrypted <%25= root_pass %25>
    
    # required for kickstart
    autopart --firstdisk --overwritevmfs
    
    # required for kickstart (foreman doesn't do static IPs yet so will need a way to get around this)
    # if this option is missing the installer will use dhcp
    #network --addvmportgroup=true --device=vmnic0 --vlanid=127 --bootproto=static --ip=10.0.x.3 --netmask=255.255.255.0 
    #--gateway=10.0.x.x --nameserver=10.0.x.1,10.0.x.2 --hostname <%25= @host %25>
    
    <%25 if @dynamic -%25>
    %25include /tmp/diskpart.cfg
    <%25 else -%25>
    <%25= @host.diskLayout %25>
    <%25 end -%25>
    
    reboot
    #%25post
    #/usr/bin/sleep 90
    # Setup ALUA
    #/usr/sbin/esxcli nmp satp setdefaultpsp --satp VMW_SATP_ALUA --psp VMW_PSP_RR
    
    # Create vSwitch0, VMMotion1 and the Service Console port group
    #/usr/sbin/esxcfg-vswitch -a vSwitch1
    # Associate vnics to vswitch
    #/usr/sbin/esxcfg-vswitch -L vmnic2 vSwitch1
    #/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch1
    #/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch0
    #/usr/sbin/esxcfg-vswitch -A 10.0.x vSwitch1
    #/usr/sbin/esxcfg-vswitch -A 10.0.x vSwitch1
    # configure the VLAN ids if any
    #/usr/sbin/esxcfg-vswitch -p 10.0.x -v 30 vSwitch1
    #/usr/sbin/esxcfg-vswitch -p 10.0.x -v 23 vSwitch1
    #/usr/sbin/esxcfg-vswitch -A VMkernel vSwitch0
    # configure the VLAN ids if any
    #/usr/sbin/esxcfg-vswitch -p VMkernel -v 12 vSwitch0
    #/usr/sbin/esxcfg-vswitch -D "VM Network" vSwitch0
    # Add a virtual switch
    #/usr/sbin/esxcfg-vswitch -A "Management Network"  vSwitch0
    # configure the VLAN ids if any
    #/usr/sbin/esxcfg-vswitch -p "Management Network" -v 12 vSwitch0
    # Add VM Kernel Interface
    #/usr/sbin/esxcfg-vmknic -a -i 10.0.x.x -n 255.255.255.0 "VMkernel" 
    #/usr/sbin/esxcfg-route 10.0.x.x
    
    # Enable Vmotion on Vkernel
    #/usr/bin/vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0
    
    # Inform the build system that we are done.
    echo "Informing Foreman that we are built" 
    wget -q -O /dev/null --no-check-certificate <%25= foreman_url %25>
    
    

Create a ESX pxe or gpxe template for ESX in foreman
  1. More-->provisioning Templates-->new
  2. Type: pxelinux or gpxe (untested with gpxe)
  3. Name: esxi-pxe
  4. Assign the template to the ESXi operating system that you defined earlier
    Do not change anything other than the name and location (boot/vmware) of the template.
    All the files are required and must be in this exact order and with "---" separating each file
    The files referenced below should be referenced from the root of your tftpboot folder /var/lib/tftpboot/boot/vmware/


default ESXi4u1HP-x86_64
LABEL ESXi4u1HP-x86_64
        kernel /boot/vmware/mboot.c32
        MENU LABEL ESXi4u1HP-x86_64        
        append boot/vmware/vmkboot.gz ks=<%25= foreman_url("provision")%25> --- boot/vmware/vmkernel.gz --- boot/vmware/sys.vgz --- boot/vmware/cim.vgz --- boot/vmware/ienviron.vgz --- boot/vmware/install.vgz

Additional Steps
  1. Assign the partition table to the ESXi operating system that you defined earlier
  2. Assign the two templates (kickstart, esx-pxe ) to the operating system you defined earlier (more-->operating system-->esx-->templates

Note: Currently you will need to staticly assign the network properties in the kickstart each time until foreman can handle these dynamic attributes
Note: This kickstart will overwrite the vmfs volume so please be careful.
Note: If you remove the the network part the installer will use dhcp and you will need to define your settings after the install.

Please see the following websites on how to further automate esx settings so your host is ready to go after install

http://www.virtuallyghetto.com/2010/09/automating-esxi-41-kickstart-tips.html
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1012248

Updated by Corey Osman almost 13 years ago · 23 revisions