Deploying vCAC/vRA Appliances with PowerCLI

Overview

I’ve been deploying vCAC/vRA quite a bit in my lab and I thought it was time to look into using PowerCLI to automate some of the pieces.  Most of what I’ve done was taken from PowerCLI 5.8 New Feature: Get-OvfConfiguration (Part 1 of 2).

The first example is more basic and won’t use any programming constructs such as loops.  There are separate sections for the vRA SSO and vRA Core appliances and most of the information is redundant.  On the $ovaConfig lines, the details such as common.varoot_password can be found by running the command

$ovaConfig.ToHashTable() | ft -auto

SSO Appliance


connect-viserver localhost

$ovaPath = 'z:\vcac\VMware-Identity-Appliance-2.1.0.0-2007605_OVF10.ova'
$ovaConfig = Get-OvfConfiguration $ovaPath

$ovaConfig.Common.vami.hostname.value                    = 'vcac61a-sso.vmware.local'
$ovaConfig.common.varoot_password.value                  = 'vmware123'
$ovaConfig.common.va_ssh_enabled.value                   = $true
$ovaConfig.IpAssignment.IpProtocol.Value                 = 'IPv4'
$ovaConfig.NetworkMapping.Network_1.Value                = Get-VDSwitch 'vDS1' | Get-VDPortgroup 'vlan3_mgmt'
$ovaConfig.vami.VMware_Identity_Appliance.ip0.value      = '192.168.3.88'
$ovaConfig.vami.VMware_Identity_Appliance.netmask0.value = '255.255.255.0'
$ovaConfig.vami.VMware_Identity_Appliance.gateway.value  = '192.168.3.1'
$ovaConfig.vami.VMware_Identity_Appliance.DNS.value      = '192.168.1.254'

$cluster = get-cluster 'compute2'
$clusterHosts = $cluster | get-vmhost
# Find a random host in the cluster
$vmHost = $clusterHosts[$(get-random -minimum 0 -maximum $clusterHosts.length)]
$datastore = $cluster | get-datastore 'nfs-ds412-hybrid0'

Import-VApp -name vcac61a-sso $ovaPath -OvfConfiguration $ovaConfig -VMHost $vmHost -datastore $datastore -DiskStorageFormat EagerZeroedThick | start-vm

Core Appliance

connect-viserver localhost
$ovaPath = 'z:\vcac\VMware-vCAC-Appliance-6.1.0.0-2077124_OVF10.ova'
$ovaConfig = Get-OvfConfiguration $ovaPath

$ovaConfig.Common.vami.hostname.value                = 'vcac61a.vmware.local'
$ovaConfig.common.varoot_password.value              = 'vmware123'
$ovaConfig.common.va_ssh_enabled.value               = $true
$ovaConfig.IpAssignment.IpProtocol.Value             = 'IPv4'
$ovaConfig.NetworkMapping.Network_1.Value            = Get-VDSwitch 'vDS1' | Get-VDPortgroup 'vlan3_mgmt'
$ovaConfig.vami.VMware_vCAC_Appliance.ip0.value      = '192.168.3.89'
$ovaConfig.vami.VMware_vCAC_Appliance.netmask0.value = '255.255.255.0'
$ovaConfig.vami.VMware_vCAC_Appliance.gateway.value  = '192.168.3.1'
$ovaConfig.vami.VMware_vCAC_Appliance.DNS.value      = '192.168.1.254'

$cluster = get-cluster 'compute2'
$clusterHosts = $cluster | get-vmhost</pre>
# Find a random host in the cluster
$vmHost = $clusterHosts[$(get-random -minimum 0 -maximum $clusterHosts.length)]
$datastore = $cluster | get-datastore 'nfs-ds412-hybrid0'

Import-VApp -name vcac61a $ovaPath -OvfConfiguration $ovaConfig -VMHost $vmHost -datastore $datastore -DiskStorageFormat EagerZeroedThick | start-vm

Alternate Method

The second method is a little more complex and uses loops, hashes, etc.  I’m probably going to redo this at some point to allow me to specify all appliances or a subset of all appliances to deploy.

# Defaults
$vCenter       = 'localhost'
$password      = 'vmware123';
$sshEnabled    = $true;
$ipProtocol    = 'IPv4';
$vSwitchName   = 'vDS1';
$portgroup     = 'vlan3_mgmt';
$netmask       = '255.255.255.0';
$gateway       = '192.168.3.1';
$dns           = '192.168.1.254';
$powerOn       = $true;
$clusterName   = 'compute2';
$datastoreName = 'nfs-ds412-hybrid0';

connect-viserver $vCenter

$ovfInfo = @{
  VMware_Identity_Appliance = @{
    path       = 'z:\vcac\VMware-Identity-Appliance-2.1.0.0-2007605_OVF10.ova';
    hostname   = 'vcac61a-sso.vmware.local';
    ipAddress  = '192.168.3.88';
  };
  VMware_vCAC_Appliance = @{
    path       = 'z:\vcac\VMware-vCAC-Appliance-6.1.0.0-2077124_OVF10.ova';
    hostname   = 'vcac61a.vmware.local';
    ipAddress  = '192.168.3.89';
  };
}

$ovfInfo.keys | % {
  $ovfConfig = @{
    "vami.hostname"            = $ovfInfo[$_].hostname;
    "varoot-password"          = $password;
    "va-ssh-enabled"           = $sshEnabled;
    "IpAssignment.IpProtocol"  = $ipProtocol;
    "NetworkMapping.Network 1" = $portgroup
    "vami.ip0.$_"              = $ovfInfo[$_].ipAddress;
    "vami.netmask0.$_"         = $netmask;
    "vami.gateway.$_"          = $gateway;
    "vami.DNS.$_"              = $dns;
 };

 $cluster      = get-cluster $clusterName
 $datastore    = $cluster | get-datastore $datastoreName
 $clusterHosts = $cluster | get-vmhost
 # Find a random host in the cluster
 $vmHost       = $clusterHosts[$(get-random -minimum 0 -maximum $clusterHosts.length)]
 $vmName       = ($ovfInfo[$_].hostname).split('.')[0]
 $ovfPath      = $ovfInfo[$_].path

 $deployedVM = Import-VApp -name $vmName $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost -datastore $datastore -DiskStorageFormat thin

 if ($deployedVM -and $powerOn) { $deployedVM | start-vm }
}

I’m not sure if it’s possible, but the next step would be to figure out how to configure settings such as SSO and certificates within the appliances.  The main goal of this exercise was to get more familiar with the new Get-OvfConfiguration commandlet.

Here is a version of the script that will work with vRA 6.2:

# Defaults
$vCenter       = 'localhost'
$password      = 'vmware123';
$sshEnabled    = $true;
$ipProtocol    = 'IPv4';
$vSwitchName   = 'vDS1';
$portgroup     = 'vlan3_mgmt';
$netmask       = '255.255.255.0';
$gateway       = '192.168.3.1';
$dns           = '192.168.1.254';
$powerOn       = $true;
$clusterName   = 'compute2';
$datastoreName = 'nfs-ds412-hybrid0';
 
connect-viserver $vCenter
 
$ovfInfo = @{
  VMware_Identity_Appliance = @{
    path       = 'z:\vra\VMware-Identity-Appliance-2.2.0.0-2300183_OVF10.ova';
    hostname   = 'vra62z-sso.vmware.local';
    ipAddress  = '192.168.3.100';
  };
  VMware_vRealize_Appliance = @{
    path       = 'z:\vra\VMware-vCAC-Appliance-6.2.0.0-2330392_OVF10.ova';
    hostname   = 'vra62z.vmware.local';
    ipAddress  = '192.168.3.101';
  };
}
 
$ovfInfo.keys | % {
  $ovfConfig = @{
    "vami.hostname"            = $ovfInfo[$_].hostname;
    "varoot-password"          = $password;
    "va-ssh-enabled"           = $sshEnabled;
    "IpAssignment.IpProtocol"  = $ipProtocol;
    "NetworkMapping.Network 1" = $portgroup
    "vami.ip0.$_"              = $ovfInfo[$_].ipAddress;
    "vami.netmask0.$_"         = $netmask;
    "vami.gateway.$_"          = $gateway;
    "vami.DNS.$_"              = $dns;
 };
 
 $cluster      = get-cluster $clusterName
 $datastore    = $cluster | get-datastore $datastoreName
 $clusterHosts = $cluster | get-vmhost
 # Find a random host in the cluster
 $vmHost       = $clusterHosts[$(get-random -minimum 0 -maximum $clusterHosts.length)]
 $vmName       = ($ovfInfo[$_].hostname).split('.')[0]
 $ovfPath      = $ovfInfo[$_].path
 
 $deployedVM = Import-VApp -name $vmName $ovfPath -OvfConfiguration $ovfConfig -VMHost $vmHost -datastore $datastore -DiskStorageFormat thin
 
 if ($deployedVM -and $powerOn) { $deployedVM | start-vm }
}
Advertisements

2 Comments on “Deploying vCAC/vRA Appliances with PowerCLI”

  1. AZM says:

    Hi, I tried your 3rd script Alternate method one, deploying vCAC IA and vCAC appliance. OVA file were deployed successfully but only SSO vm was configured with Network Configuration ,in vCAC appliance there was only hostname, no network config. Let me know if you come across this issue in your tests. Actually, I am trying to use your script to deploy multiple vCAC appliances but stuck with this issue. BTW, thanks for the script, really great work.

    • Chris Greene says:

      What version of vCAC/vRA were you using? If you were trying to deploy vRA 6.2, it won’t work with this script. I’ll update the post with a version that will work.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s