Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
sflinks = [
[ 'vmware-esx-base', 'vcenter-vm-base' ],
[ 'vmware-esx-base', 'manual-foundation-base' ],
[ 'vmware-esx-base', 'amt-base' ],
[ 'vmware-esx-base', 'ipmi-base' ],
[ 'vmware-vca-base', 'vcenter-vm-base' ]
]
[ structure.vmware-esx-base ]
description = 'Base ESX'
scripts = { 'create' = 'create-esx', 'destroy' = 'destroy-esx' }
[ structure.vmware-esx-base.config_values ]
root_password_hash = '$6$rootroot$oLo.loyMV45VA7/0sKV5JH/xBAXiq/igL4hQrGz3yd9XUavmC82tZm1lxW2N.5eLxQUlqp53wXKRzifZApP0/1'
memory_size = 4096
cpu_count = 2
disk_provisioning = 'thin'
vcenter_network_interface_class = 'VMXNet3'
vcenter_guest_id = 'vmkernel6Guest'
vcenter_virtual_exec_usage = 'on'
vcenter_virtual_mmu_usage = 'on'
vcenter_virtual_vhv = true
datastore_list = []
[ script.create-esx ]
description = 'Install ESX'
script = """# pxe boot and install
dhcp.set_pxe( interface=structure.provisioning_interface, pxe='esx' )
foundation.power_on()
delay( seconds=120 )
foundation.wait_for_poweroff()
dhcp.set_pxe( interface=structure.provisioning_interface, pxe='normal-boot' )
foundation.power_on()
iputils.wait_for_port( target=structure.primary_ip, port=80 )
# after the first boot, the network may come up while the script runs
delay( seconds=120 )
# now it is rebooting, so wait for it to come up again
iputils.wait_for_port( target=structure.primary_ip, port=80 )
# a little margin before we start doing anything, hopfully the quickstats get updated in this time
delay( seconds=30 )
datastore_list = config.datastore_list
while len( array=datastore_list ) do
begin()
datastore = pop( array=datastore_list )
vcenter.create_datastore( name=datastore[ 'name' ], model=datastore[ 'model' ] )
end
"""
[ script.destroy-esx ]
description = 'Uninstall ESX'
script = """# nothing to do, foundation cleanup should wipe/destroy the disks
foundation.power_off()
#eventually pxe boot to MBR wipper
"""
[ pxe.esx ]
boot_script = """echo ESX Installer
kernel -n mboot.c32 {{ __pxe_location }}vmware/esx-installer/mboot.c32
imgargs mboot.c32 -c {{ __pxe_location }}vmware/esx-installer/boot.cfg ks={{ __pxe_template_location }}
boot mboot.c32
"""
template = """{% set network = _primary_address %}
accepteula
{% if esx_license_key %}
serialnum --esx={{ esx_license_key }}
{% endif %}
rootpw --iscrypted {{ root_password_hash }}
clearpart --alldrives --overwritevmfs
install --firstdisk --overwritevmfs
network --bootproto=dhcp
#network --bootproto=static --device={{ _primary_interface_mac }} --ip={{ network.address }} --netmask={{ network.netmask }}{% if network.gateway %} --gateway={{ network.gateway }}{% endif %} --nameserver={{ dns_servers.0 }} --hostname={{ _hostname }}
%firstboot --interpreter=busybox
sleep 10
echo 'Remove Default vSwitch...'
esxcli network ip interface remove --portgroup-name='Management Network'
esxcli network vswitch standard portgroup remove --vswitch-name=vSwitch0 --portgroup-name='Management Network'
esxcli network vswitch standard portgroup remove --vswitch-name=vSwitch0 --portgroup-name='VM Network'
esxcli network vswitch standard remove --vswitch-name=vSwitch0
echo 'Setting hostname...'
esxcli system hostname set --domain {{ _domain_name }} --host {{ _hostname }}
{% set counter = [ 0 ] %}
{% for do_primary in ( True, False ) %}
{% for interface in _interface_map.values() %}
{% set is_primary = ( interface.name == _primary_interface ) %}
{% if do_primary == is_primary %}
{% set address = interface.address_list.0 %}
{% set vswitch = 'vSwitch' + counter.0|string %}
{% set vmk = 'vmk' + counter.0|string %}
echo 'Configure Interface {{ interface.name }}...'
esxcli network vswitch standard add --vswitch-name={{ vswitch }}
esxcli network vswitch standard uplink add --vswitch-name={{ vswitch }} --uplink-name={{ interface.name }}
esxcli network vswitch standard portgroup add --vswitch-name={{ vswitch }} --portgroup-name='{{ interface.network }}'
esxcli network vswitch standard portgroup add --vswitch-name={{ vswitch }} --portgroup-name='Managment {{ interface.network }}'
esxcli network ip interface add --interface-name={{ vmk }} --portgroup-name='Managment {{ interface.network }}'
esxcli network ip interface ipv4 set --interface-name={{ vmk }} --type=static --ipv4={{ address.address }} --netmask={{ address.netmask }}
esxcli network ip interface tag add --interface-name={{ vmk }} --tagname=Management
{% if address.gateway %}
esxcli network ip route ipv4 add --network=default --gateway={{ address.gateway }}
{% endif %}
{% set _ = counter.append( counter.pop() + 1 ) %}
{% endif %}
{% endfor %}
{% endfor %}
echo 'Set DNS...'
{% for server in dns_servers %}
esxcli network ip dns server add --server={{ server }}
{% endfor %}
#echo 'Enable SSH...'
#vim-cmd hostsvc/enable_ssh
echo 'Set NTP...'
esxcli system ntp set --server {{ ntp_servers|join( " --server " ) }} --enabled true
echo 'Disable CEIP...'
esxcli system settings advanced set -o /UserVars/HostClientCEIPOptIn -i 2
echo 'Done.'
/sbin/reboot
%post --interpreter=busybox --ignorefailure=false
echo 'Power off...'
/sbin/poweroff
"""
[ structure.vmware-vca-base ]
description = 'Base VCA'
scripts = { 'create' = 'create-vca', 'destroy' = 'destroy-vca' }
[ structure.vmware-vca-base.config_values ]
root_password_plain = 'VMware1!'
ova = '{{ __pxe_location }}vmware/vcenter.ova'
cpu_count = 2
memory_size = 2048
disk_provisioning = 'thin'
vcenter_deployment_option = 'tiny' # tiny,small,medium,large,management-tiny,management-small,management-medium,management-large,infrastructure
vcenter_ip_protocol = 'IPv4'
[ structure.vmware-vca-base.config_values.vcenter_property_map ]
'guestinfo.cis.appliance.net.addr.family' = 'ipv4'
'guestinfo.cis.appliance.net.mode' = 'static'
'guestinfo.cis.appliance.net.addr' = '{{ _foundation_interface_list.0.address_list.0.address }}'
'guestinfo.cis.appliance.net.pnid' = '{{ _fqdn }}'
'guestinfo.cis.appliance.net.prefix' = '{{ _foundation_interface_list.0.address_list.0.prefix }}'
'guestinfo.cis.appliance.net.gateway' = '{{ _foundation_interface_list.0.address_list.0.gateway }}'
'guestinfo.cis.appliance.net.dns.servers' = '{{ dns_servers|join( "," ) }}'
'guestinfo.cis.appliance.ntp.servers' = '{{ ntp_servers|join( "," ) }}'
'guestinfo.cis.appliance.root.passwd' = '{{ root_password_plain }}'
'guestinfo.cis.appliance.ssh.enabled' = 'True'
'guestinfo.cis.vmdir.domain-name' = '{{ domain_name }}'
'guestinfo.cis.vmdir.site-name' = '{{ _site }}'
'guestinfo.cis.vmdir.password' = '{{ root_password_plain }}'
'guestinfo.cis.deployment.node.type' = 'embedded'
'guestinfo.cis.ceip_enabled' = 'False'
domain = '{{ domain_name }}'
searchpath = '{{ dns_search|join( "," ) }}'
vmname = '{{ _hostname }}'
[ script.create-vca ]
description = 'Install VCA'
script = """# installed by OVA during foundation deploy
foundation.power_on()
delay( seconds=300 )
iputils.wait_for_port( target=structure.primary_ip, port=443 )
# wait a few seconds for it to reboot, and make sure the port openes again, just incase we got an open port before it rebooted
delay( seconds=30 )
iputils.wait_for_port( target=structure.primary_ip, port=443 )
"""
[ script.destroy-vca ]
description = 'Uninstall VCA'
script = """# nothing to do, foundation cleanup should wipe/destroy the disks
foundation.power_off()
#eventually pxe boot to MBR wipper
"""