Wednesday, March 4, 2015

Automating vCenter Server Appliance 6 with ovftool 4

#Deploy vCSA without vCenter directly to the ESXi
#Type 1 : Full Install
#Variables
$ESXi = ""
$OvfFile = ""
$DC = ""
$SourceDatastore = ""
#If not using the file on the datastore then use the path to ova file and delete all the above parameters replace the below url with a path to the ova
$vCsaFile = "https://$ESXi/folder/$OvfFile/vcsa.ovf?dcPath=$DC&dsName=$SourceDatastore"
$vCsaConf = Get-OvfConfiguration $vCsaOva
$vCsaName = ""
$vCsaPG = "VM Network"
$AMPhost = ""
$Datastore = ""
$Network = Get-VirtualPortGroup -Name $vCsaPG -VMHost $AMPhost
$vCSAIP = ""
$DNS = ""
$SubnetPrefix = ""
$gateway = ""
$rootPASS = ""
$DNSsuffix = ""
$SiteName = ""
$vCSAssoPass = ""
$NTP1 = ""
$Format = ""

#Config
$vCsaConf.NetworkMapping.Network_1.value = "$vCsaPG"
$ovfconfig.DeploymentOption.value = "management-medium"
$ovfconfig.Common.guestinfo.cis.appliance.net.mode.value = "static"
$ovfconfig.IpAssignment.IpProtocol.value = "IPv4"
$ovfconfig.Common.guestinfo.cis.appliance.net.addr.family.value = "ipv4"
$ovfconfig.Common.guestinfo.cis.appliance.net.addr_1.value = "$vCSAIP"
$ovfconfig.Common.guestinfo.cis.appliance.net.pnid.value  = "$vCSAIP"
$ovfconfig.Common.guestinfo.cis.appliance.net.prefix.value = "$SubnetPrefix"
$ovfconfig.Common.guestinfo.cis.appliance.net.gateway.value = "$gateway"
$ovfconfig.Common.guestinfo.cis.appliance.net.dns.servers.value = "$DNS"
$ovfconfig.Common.guestinfo.cis.appliance.ssh.enabled.value = "True"
$ovfconfig.Common.guestinfo.cis.vmdir.domain_name.value = "$DNSsuffix"
$ovfconfig.Common.guestinfo.cis.vmdir.site_name.value = "$SiteName"
$ovfconfig.Common.guestinfo.cis.vmdir.password.value = "$vCSAssoPass"
$ovfconfig.Common.guestinfo.cis.appliance.root.passwd.value = "$rootPASS"
$ovfconfig.Common.guestinfo.cis.appliance.ntp.servers.value = "$NTP1"

#Deploy
Import-VApp -Source $vCsaFile -OvfConfiguration $vCsaConf -Name $vCsaName -VMHost $AMPhost -Datastore $Datastore -DiskStorageFormat $Format
#End Notes