Project

General

Profile

VMware ESXi » History » Version 17

Corey Osman, 12/27/2011 11:11 PM

1 1 Corey Osman
h1. How to Provision a VMware ESXi server using foreman
2
3
Although puppet will not run under ESX server we can still use foreman to kickstart the server using PXE.
4
5
h2. Summary of what you need to do:
6
# Copy iso contents of ESXi to your media directory
7
# Copy the esx boot files to your tftp directory
8 8 Corey Osman
# Create a ESX Installation Medium in Foreman
9 1 Corey Osman
# Create a ESX operating system in foreman
10
# Create a ESX partition table (optional) template
11
# Create a ESX kickstart template in foreman
12
# Create a ESX pxe or gpxe template for ESX in foreman
13
14
15 4 Corey Osman
h3. Copy iso contents of ESXi to your media directory (example only)
16 1 Corey Osman
<pre>
17 6 Corey Osman
mkdir /mnt/iso1
18
mkdir -p /var/www/html/repos/vmware/esxi4.1/  
19 5 Corey Osman
mount -o loop esxi-iso-file.iso /mnt/iso1  (example for RHEL based distros)
20 4 Corey Osman
rsync -avz /mnt/iso1/ /var/www/html/repos/vmware/esxi4.1/
21
</pre>
22
23 7 Corey Osman
h3. Copy the esx boot files to your tftp directory  (must have all of these)
24 4 Corey Osman
<pre>
25
cp /var/www/html/repos/vmware/esxi4.1/mboot.c32 /var/lib/tftpboot/boot/vmware/
26
cp /var/www/html/repos/vmware/esxi4.1/vmkboot.gz /var/lib/tftpboot/boot/vmware/
27
cp /var/www/html/repos/vmware/esxi4.1/vmkernel.gz /var/lib/tftpboot/boot/vmware/
28
cp /var/www/html/repos/vmware/esxi4.1/sys.vgz /var/lib/tftpboot/boot/vmware/
29
cp /var/www/html/repos/vmware/esxi4.1/cim.vgz /var/lib/tftpboot/boot/vmware/
30
cp /var/www/html/repos/vmware/esxi4.1/ienviron.vgz /var/lib/tftpboot/boot/vmware/
31
cp /var/www/html/repos/vmware/esxi4.1/install.vgz /var/lib/tftpboot/boot/vmware/
32
33 2 Corey Osman
</pre>
34 8 Corey Osman
35 9 Corey Osman
h3. Create the installation medium based on where you put your esx4.1 iso contents
36
# Create new medium
37
# vmware
38
# path: http://192.168.1.88/repos/vmware/esxi$version/  (example only)
39
# OS: ESXi4.1  (can define later after making operating system)
40
41 8 Corey Osman
h3. Create a ESX operating system in foreman (Example only)
42
# More-->Operating Systems-->New
43
# Name: ESXi
44
# Major: 4
45
# Minor 1
46
# OS Family: Redhat (there is no vmware yet)
47
# Arch: x86_64
48
# Choose any partition tables if you defined any (can do later)
49 1 Corey Osman
# Choose the vmware installation media (can do later) 
50
51 10 Corey Osman
 h3. Create a Partition table in Foreman (optional)
52 1 Corey Osman
# Name: esxi4.1 (name whatever you need to)
53 13 Corey Osman
# Assign the template to the ESXi operating system that you defined earlier
54 9 Corey Osman
# Layout:  (Something like the following)
55
<pre>
56
part '/boot'  --fstype=ext3 --size=1100  --ondisk=mpx.vmhba0:C0:T0:L0
57
part 'none'  --fstype=vmkcore --size=110  --ondisk=mpx.vmhba0:C0:T0:L0
58
part 'datastore1'  --fstype=vmfs3 --size=9004 --grow  --ondisk=mpx.vmhba0:C0:T0:L0
59
virtualdisk 'esxconsole' --size=8004 --onvmfs='datastore1'
60
61
part 'swap'  --fstype=swap --size=1000 --onvirtualdisk='esxconsole'
62
part '/var/log'  --fstype=ext3 --size=2000 --onvirtualdisk='esxconsole'
63
part '/'  --fstype=ext3 --size=5000 --grow --onvirtualdisk='esxconsole'
64 1 Corey Osman
</pre>
65 10 Corey Osman
66
h3. Create a ESX kickstart template in foreman
67 11 Corey Osman
# More-->provisioning Templates-->new
68
# Type: provision
69
# Name: esxi
70
# Use something like the following for the template:
71
<pre>
72 16 Corey Osman
vmaccepteula
73 1 Corey Osman
74 11 Corey Osman
install url <%25= @mediapath %25>
75 16 Corey Osman
# Set the root password for the DCUI and Tech Support Mode
76 11 Corey Osman
rootpw --iscrypted <%25= root_pass %25>
77
78
# required for kickstart
79
autopart --firstdisk --overwritevmfs
80
81 16 Corey Osman
# Set the network to DHCP on the first network adapater
82
network --bootproto=dhcp --device=vmnic0
83
84 11 Corey Osman
# required for kickstart (foreman doesn't do static IPs yet so will need a way to get around this)
85
# if this option is missing the installer will use dhcp
86 1 Corey Osman
#network --addvmportgroup=true --device=vmnic0 --vlanid=127 --bootproto=static --ip=10.0.x.3 --netmask=255.255.255.0 
87
#--gateway=10.0.x.x --nameserver=10.0.x.1,10.0.x.2 --hostname <%25= @host %25>
88 11 Corey Osman
89
90
<%25 if @dynamic -%25>
91
%25include /tmp/diskpart.cfg
92
<%25 else -%25>
93
<%25= @host.diskLayout %25>
94 1 Corey Osman
<%25 end -%25>
95
96 16 Corey Osman
# A sample post-install script
97
%25post --unsupported --ignorefailure=true
98 11 Corey Osman
99
# Inform the build system that we are done.
100
echo "Informing Foreman that we are built"
101
wget -q -O /dev/null --no-check-certificate <%25= foreman_url %25>
102
103
</pre>
104
105
h3. Create a ESX pxe or gpxe template for ESX in foreman
106 1 Corey Osman
# More-->provisioning Templates-->new
107
# Type: pxelinux or gpxe (untested with gpxe)
108 12 Corey Osman
# Name: esxi-pxe
109
# Assign the template to the ESXi operating system that you defined earlier
110 1 Corey Osman
Do not change anything other than the name and location (boot/vmware) of the template.
111 13 Corey Osman
All the files are required and must be in this exact order and with "---" separating each file
112 12 Corey Osman
The files referenced below should be referenced from the root of your tftpboot folder  /var/lib/tftpboot/boot/vmware/
113
114
<pre>
115
116
default ESXi4u1HP-x86_64
117
LABEL ESXi4u1HP-x86_64
118
        kernel /boot/vmware/mboot.c32
119
        MENU LABEL ESXi4u1HP-x86_64        
120
        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
121
</pre>
122
123 1 Corey Osman
h3. Additional Steps
124 13 Corey Osman
# Assign the partition table to the ESXi operating system that you defined earlier
125
# Assign the two templates (kickstart, esx-pxe ) to the operating system you defined earlier (more-->operating system-->esx-->templates
126
127
Note:  Currently you will need to staticly assign the network properties in the kickstart each time until foreman can handle these dynamic attributes
128 14 Corey Osman
Note:  This kickstart will overwrite the vmfs volume so please be careful.  
129
Note:  If you remove the the network part the installer will use dhcp and you will need to define your settings after the install.
130
131
Please see the following websites on how to further automate esx settings so your host is ready to go after install
132
133
http://www.virtuallyghetto.com/2010/09/automating-esxi-41-kickstart-tips.html
134
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1012248
135 16 Corey Osman
136 17 Corey Osman
"Vmware Kickstart Options":http://www.vmware.com/pdf/vsphere4/r41/vsp_41_esxi_i_vc_setup_guide.pdf