Project

General

Profile

VMware ESXi » History » Version 11

Corey Osman, 12/27/2011 10:37 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 10 Corey Osman
# Operating System: ESXi 4.1
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
accepteula
73
74
variable: <%25= vlan %25>
75
76
# Canonical drive names:
77
#clearpart --drives=mpx.vmhba0:C0:T0:L0
78
# Uncomment to use first detected disk:
79
#clearpart --firstdisk
80
81
# Uncomment the esxlocation line and comment out the clearpart
82
# and physical partitions to do a non-destructive reinstall.
83
#esxlocation --uuid=881475a6-700a-4b33-aa24-048909df6c14
84
install url <%25= @mediapath %25>
85
86
rootpw --iscrypted <%25= root_pass %25>
87
88
# required for kickstart
89
autopart --firstdisk --overwritevmfs
90
91
# required for kickstart (foreman doesn't do static IPs yet so will need a way to get around this)
92
# if this option is missing the installer will use dhcp
93
#network --addvmportgroup=true --device=vmnic0 --vlanid=127 --bootproto=static --ip=10.0.x.3 --netmask=255.255.255.0 
94
#--gateway=10.0.x.x --nameserver=10.0.x.1,10.0.x.2 --hostname <%25= @host %25>
95
96
97
<%25 if @dynamic -%25>
98
%25include /tmp/diskpart.cfg
99
<%25 else -%25>
100
<%25= @host.diskLayout %25>
101
<%25 end -%25>
102
103
reboot
104
#%25post
105
#/usr/bin/sleep 90
106
# Setup ALUA
107
#/usr/sbin/esxcli nmp satp setdefaultpsp --satp VMW_SATP_ALUA --psp VMW_PSP_RR
108
109
# Create vSwitch0, VMMotion1 and the Service Console port group
110
#/usr/sbin/esxcfg-vswitch -a vSwitch1
111
# Associate vnics to vswitch
112
#/usr/sbin/esxcfg-vswitch -L vmnic2 vSwitch1
113
#/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch1
114
#/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch0
115
#/usr/sbin/esxcfg-vswitch -A 10.0.x vSwitch1
116
#/usr/sbin/esxcfg-vswitch -A 10.0.x vSwitch1
117
# configure the VLAN ids if any
118
#/usr/sbin/esxcfg-vswitch -p 10.0.x -v 30 vSwitch1
119
#/usr/sbin/esxcfg-vswitch -p 10.0.x -v 23 vSwitch1
120
#/usr/sbin/esxcfg-vswitch -A VMkernel vSwitch0
121
# configure the VLAN ids if any
122
#/usr/sbin/esxcfg-vswitch -p VMkernel -v 12 vSwitch0
123
#/usr/sbin/esxcfg-vswitch -D "VM Network" vSwitch0
124
# Add a virtual switch
125
#/usr/sbin/esxcfg-vswitch -A "Management Network"  vSwitch0
126
# configure the VLAN ids if any
127
#/usr/sbin/esxcfg-vswitch -p "Management Network" -v 12 vSwitch0
128
# Add VM Kernel Interface
129
#/usr/sbin/esxcfg-vmknic -a -i 10.0.x.x -n 255.255.255.0 "VMkernel"
130
#/usr/sbin/esxcfg-route 10.0.x.x
131
132
# Enable Vmotion on Vkernel
133
#/usr/bin/vmware-vim-cmd hostsvc/vmotion/vnic_set vmk0
134
135
# Inform the build system that we are done.
136
echo "Informing Foreman that we are built"
137
wget -q -O /dev/null --no-check-certificate <%25= foreman_url %25>
138
139
</pre>
140
141 10 Corey Osman
h3. Create a ESX pxe or gpxe template for ESX in foreman