forked from LiamLeane/Foreman-ESXi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.erb
59 lines (49 loc) · 1.77 KB
/
provision.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%#
kind: provision
name: ESXi provision
oses:
- ESXi 5
- ESXi 5.5
- ESXi 6
%>
<%#
This template accepts the following parameters:
- ntp-server: string (default="0.pool.ntp.org")
%>
vmaccepteula
# Set the root password
rootpw --iscrypted <%= root_pass %>
# Install ESX
<%= @host.diskLayout %>
# First interface IP configuration
<% subnet = @host.subnet -%>
<% identifier = @host.provision_interface.identifier.present? ? @host.provision_interface.identifier : 'vmnic0'%>
<% if subnet.respond_to?(:dhcp_boot_mode?) && subnet.dhcp_boot_mode? -%>
network --bootproto=dhcp --device=<%= identifier -%>
<% else -%>
network --bootproto=static --ip=<%= @host.ip -%> --gateway=<%= subnet.gateway -%> --nameserver=<%= subnet.dns_primary -%> --netmask=<%= subnet.mask -%> --hostname=<%= @host.name -%> --device=<%= identifier -%> --addvmportgroup=0
<% end -%>
%post --interpreter=busybox
#Notify foreman
wget -q -O /dev/null <%= foreman_url %>
reboot
# Configure additional commands at first boot.
%firstboot --interpreter=busybox
#Enable shell access
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell
/adv/UserVars/SuppressShellWarning = "1"
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1
#Enable NTP
echo restrict default kod nomodify notrap noquerynopeer > /etc/ntp.conf
echo restrict 127.0.0.1 >> /etc/ntp.conf
echo server <%= @host.params['ntp-server'] || '0.pool.ntp.org' %> >> /etc/ntp.conf
echo driftfile /var/lib/ntp/drift >> /etc/ntp.conf
/sbin/chkconfig -level 345 ntpd on
/etc/init.d/ntpd stop
/etc/init.d/ntpd start
#Add any additional esxcli commands here
# Uncomment if making changes that require a reboot
# esxcli system shutdown reboot -d 60 -r "rebooting after host configurations"