Automate HCX Manager deployment with PowerCLI
Sep 14
3 min read
2
53
0
Automate the deployment of HCX Manager and HCX Cloud using PowerCLI. In this blog post we'll explore how to use PowerCLI to automate HCX Manager deployment.
Please note, there are some prerequisites & requirements for your local system to be ready/installed with before you can run this script. Please refer to the below table of contents for the same.
Table of Contents:
PowerCLI version & Module.
Download HCX Connector & HCX Cloud OVA.
Edite/Update the PowerCLI script with your required configuration & deployment details.
Run the PowerCLI to automate the HCX Manager deployment, monitor the progress and validate post successful deployment.
1. PowerCLI version & Module:
PowerCLI 11.2.0 introduced a module that allows us to easily automate VMware HCX. To use and automate the HCX deployment from you workstation, make sure verifying the PowerCLI version & module installed on your workstation to meet the system prerequisite mentioned below for your HCX automation.
PowerCLI 11.2.0 or above.
Module: VMware.VimAutomation.Hcx
Below is the screenshot from my deployment.
2. Download HCX Connector & HCX Cloud OVA:
Visit https://https://support.broadcom.com/ to download the HCX Connector and HCX Cloud OVA. You can download the HCX Connector from HCX Cloud Manager as well, once it is deployed in target location.
3. Edite/Update the PowerCLI script with your required configuration & deployment details:
Kindly update the below PowerCLI with all the required details/values for your HCX deployment.
Please note:
Reserve/static network/ips for HCX Connector & Cloud, and make sure DNS records are updated for forward/reverse before you run the script for deployment.
Script: You can copy and past, edit before you run this, as per your required details for
deployment.
# Load OVF/OVA configuration into a variable
$ovffile = "C:\Users\Administrator\Desktop\hcx\connector.ova"
$ovfconfig = Get-OvfConfiguration $ovffile
# vSphere Cluster + VM Network configurations
$Cluster = "vSphereClusterName"
$VMName = "hcx-c-01a"
$VMNetwork = "vNICName-mgmt"
$HCXAddressToVerify = "hcx-c-01a.corp.local"
$VMHost = Get-Cluster $Cluster | Get-VMHost | Sort MemoryGB | Select -first 1
$Datastore = $VMHost | Get-datastore | Sort FreeSpaceGB -Descending | Select -first 1
$Network = Get-VDPortGroup -Name $VMNetwork
# Fill out the OVF/OVA configuration parameters
# vSphere Portgroup Network Mapping
$ovfconfig.NetworkMapping.VSMgmt.value = $Network
# IP Address
$ovfConfig.common.mgr_ip_0.value = "192.168.x.x"
# Netmask
$ovfConfig.common.mgr_prefix_ip_0.value = "16"
# Gateway
$ovfConfig.common.mgr_gateway_0.value = "192.168.x.x"
# DNS Server
$ovfConfig.common.mgr_dns_list.value = "192.168.x.x"
# DNS Domain
$ovfConfig.common.mgr_domain_search_list.value = "corp.local"
# Hostname
$ovfconfig.Common.hostname.Value = "hcx-c-01a.corp.local"
# NTP
$ovfconfig.Common.mgr_ntp_list.Value = "192.168.x.x"
# SSH
$ovfconfig.Common.mgr_isSSHEnabled.Value = $true
# Password
$ovfconfig.Common.mgr_cli_passwd.Value = "PasswordForHCX"
$ovfconfig.Common.mgr_root_passwd.Value = "PasswordForHCX"
# Deploy the OVF/OVA with the config parameters
Write-Host -ForegroundColor Green "Deploying HCX Manager OVA ..."
$vm = Import-VApp -Source $ovffile -OvfConfiguration $ovfconfig -Name $VMName -VMHost $vmhost -Datastore $datastore -DiskStorageFormat thin
# Power On the HCX Manager VM after deployment
Write-Host -ForegroundColor Green "Powering on HCX Manager ..."
$vm | Start-VM -Confirm:$false | Out-Null
# Waiting for HCX Manager to initialize
while(1) {
try {
if($PSVersionTable.PSEdition -eq "Core") {
$requests = Invoke-WebRequest -Uri "https://$($HCXAddressToVerify):9443" -Method GET -SkipCertificateCheck -TimeoutSec 5
} else {
$requests = Invoke-WebRequest -Uri "https://$($HCXAddressToVerify):9443" -Method GET -TimeoutSec 5
}
if($requests.StatusCode -eq 200) {
Write-Host -ForegroundColor Green "HCX Manager is now ready to be configured!"
break
}
}
catch {
Write-Host -ForegroundColor Yellow "HCX Manager is not ready yet, sleeping for 120 seconds ..."
sleep 120
}
}
4. Run the PowerCLI to automate the HCX Manager deployment, monitor the
progress and validate post successful deployment:
Please note, I have mentioned below & shown screenshots only for HCX Connector
However, you can use the same script to update the details with HCX Cloud and
execute it to deploy HCX Cloud.
HCX Connector FQDN: hcx-c-01a.corp.local
HCX Connector IP: 192.168.x.x
Below are the screenshots from my deployment, performed for validation & HCX deployment.
You will need to connect to your vCenter by using the Connect-VIServer comdlet
and then run the deployment script, find all the screenshots below for all the steps
performed to automate the HCX Manager deployment.
Now, if you go to your vCenter, can verify deployment has started showing up
there.
Below are the screenshots post successful deployment, verified health from
vCenter, IP, DNS Name and nslookup for resolution.
Now, try to login to HCX using port 9443 to perform further configurations.
Example, I used "https://hcx-c-01a.corp.local:9443/"
With this, you now have your HCX Connector deployed successfully, and can proceed further with HCX Cloud deployment & rest of it's configurations. All the best.