How to Automate VMware Log Insight OVA Deployments using PowerCLI

This is a quick guide on how to automate the deployment of a Log Insight instance using PowerCLI. It also reviews how to get information about various configuration options so you can work with other OVA deployments. Please note that this only gets you a VM that is configured and ready to power on. There is currently not a(n easy) way to script the configuration of the application with scripting. I have put in a feature request and it is being looked at.

First, make sure you have PowerCLI. Version 5.5 should contain the -OvfConfiguration flag. According to VMware documentation the -OvfConfiguration flag for Import-VApp is not present in 5.1. If you need to install PowerCLI it’s fairly quick.

Second, you will need to be connected to a vCenter server or ESXi host after launching PowerCLI. This is done via Connect-VIServer and specifying the IP address and credentials to be used to connect to the server.

Connect-VIServer -Server $server

Finally, you will need to have the OVA file for Log Insight downloaded to the machine you are running PowerCLI from. Keep the path to the file handy, you’ll need to specify it a couple times in the cmdlets.

The (important) cmdlets:

  • Import-VApp – used to load the OVA file into vCenter or the ESXi host
  • Get-OvfConfiguration – loads the OVF config file so that you can insert information

Also, if you have trouble remember, tab completion is your friend.

Basic Script

This is a bare bones script that has everything predefined, you can include Read-Host prompts or add additional logic for your environment if you want. I’ll include some examples at the end.

$path = "C:\path\to\ovf.ova"
$size = "Extra Small"
$vmAdapter = "VM Port Group"
$ipaddr0 = "192.168.0.2"
$netmask0 = "255.255.255.0"
$gateway = "192.168.0.1"
$hostname = "localhost"
$dnsserv = "8.8.8.8,8.8.4.4"
$password = "password"
$name = "test-loginsight"
$location = "Resource Group Default"
$vmhost = "VM host"
$datastore = "Datastore"
$ovfConfiguration = Get-OvfConfiguration -Ovf $path
$ovfConfiguration.DeploymentOptions.Value = $size
$ovfConfiguration.NetworkMapping.Network_1.Value = $vmAdapter
$ovfConfiguration.vami.VMware_vCenter_Log_Insight.ip0.Value = $ipaddr0
$ovfConfiguration.vami.VMware_vCenter_Log_Insight.netmask0.Value = $netmask0
$ovfConfiguration.vami.VMware_vCenter_Log_Insight.gateway.Value = $gateway
$ovfConfiguration.vami.VMware_vCenter_Log_Insight.hostname.Value = $hostname
$ovfConfiguration.vami.VMware_vCenter_Log_Insight.DNS.Value = $dnsserv
$ovfConfiguration.vm.rootpw.Value = $password

Import-VApp -Source $path -OvfConfiguration $ovfConfiguration -Name $name -Location $location -VMHost $vmhost -Datastore $datastore

So, that’s a lot of variables. How did I get them? Mostly tab completion, coupled with reading the vApp settings in the “Edit Settings…” as well as outputting the config as a hash table. Below is an example of what a blank config looks like.

PowerCLI C:\> $ovfConfiguration.ToHashTable() | fl

Name : vami.gateway.VMware_vCenter_Log_Insight
Value :

Name : DeploymentOption
Value :

Name : vm.sshkey
Value :

Name : vami.DNS.VMware_vCenter_Log_Insight
Value :

Name : vami.ip0.VMware_vCenter_Log_Insight
Value :

Name : vami.hostname.VMware_vCenter_Log_Insight
Value :

Name : vami.netmask0.VMware_vCenter_Log_Insight
Value :

Name : vm.rootpw
Value :

Name : NetworkMapping.Network 1
Value :

Name : IpAssignment.IpProtocol
Value :

This is the basic config with some information filled out.

PowerCLI C:\> $ovfConfiguration.ToHashTable() | fl

Name : vami.gateway.VMware_vCenter_Log_Insight
Value : 192.168.0.1

Name : DeploymentOption
Value : Extra Small

Name : vm.sshkey
Value :

Name : vami.DNS.VMware_vCenter_Log_Insight
Value : 8.8.8.8,8.8.4.4

Name : vami.ip0.VMware_vCenter_Log_Insight
Value : 192.168.0.2

Name : vami.hostname.VMware_vCenter_Log_Insight
Value : localhost

Name : vami.netmask0.VMware_vCenter_Log_Insight
Value : 255.255.255.0

Name : vm.rootpw
Value :

Name : NetworkMapping.Network 1
Value : VM Port Group

Name : IpAssignment.IpProtocol
Value :

You’ll notice I left some stuff blank. I’m not sure what the IpAssignment.IpProtocol value is for, and there’s no description (maybe if someone wants to chime in…). I also didn’t bother with the root pw or the ssh key because I don’t use either of those things usually.

If you want to get a description of the configuration option you can run the following:

$ovfConfiguration.DeploymentOption.Description

Which will output the following:

Extra Small
IMPORTANT: This configuration is intended for proof-of-concept or test environments and should not be used in a production environment.

This configuration supports up to 20 ESXi hosts (~200 events/second or ~3GB/day) and requires the following:

* 2 CPUs (minimum 2.0GHz)
* 4GB RAM
* 132GB of storage (100GB for event storage) - thick provisioned, eagerzeroed highly recommended
* VM hardware version 7 or greater (vSphere 4.0 or greater)

Small
IMPORTANT: For Log Insight clusters medium or large sized nodes should be used.

This configuration supports up to 200 ESXi hosts (~2,000 events/second or ~30GB/day) and requires the following:

* 4 CPU (minimum 2.0GHz)
* 8GB RAM
* 132GB of storage (100GB for event storage) - thick provisioned, eager zeroed highly recommended
* VM hardware version 7 or greater (vSphere 4.0 or greater)

Medium
This configuration supports up to 500 ESXi hosts (~5,000 events/second or ~75GB/day) and requires the following:

* 8 CPU (minimum 2.0GHz)
* 16GB RAM
* 282GB of storage (250GB for event storage) - thick provisioned, eager zeroed highly recommended
* VM hardware version 7 or greater (vSphere 4.0 or greater)

Large
IMPORTANT: This configuration requires vSphere 5.0 or greater.

This configuration supports up to 1,500 ESXi hosts (~15,000 events/second or ~225GB/day) and requires the following:

* 16 CPU (minimum 2.0GHz)
* 32GB RAM
* 282GB of storage (250GB for event storage) - thick provisioned, eager zeroed highly recommended
* VM hardware version 8 or greater (vSphere 5.0 or greater)

As you can see, this pertains to the size of the deployment. You will get similar (though less verbose) results for the other configurations that are listed.

Example of a more customized script

The following is an example of a slightly cleaner script that will prompt the user for information rather than using hard coded values. You can get more advanced, of course, but I’ll let you guys do that on your own.

$portgroups = $(Get-VirtualPortGroup).Name
$hosts = $(Get-VMHost).Name
$datastores = $(Get-Datastore).Name
$resourcepools = $(Get-ResourcePool).Name
$continueflag = "n"

while($continueflag -eq "n"){
   $path = Read-Host "Path to OVA file"
   $ovfConfiguration.DeploymentOptions.Value = Read-Host "$($ovfConfiguration.DeploymentOption.Description) `nDeployment Size?"
   $(Get-VirtualPortGroup).Name
   $ovfConfiguration.NetworkMapping.Network_1.Value = Read-Host "Which Port Group"
   $ovfConfiguration.vami.VMware_vCenter_Log_Insight.ip0.Value = Read-Host "IP Address"
   $ovfConfiguration.vami.VMware_vCenter_Log_Insight.netmask0.Value = Read-Host "Netmask"
   $ovfConfiguration.vami.VMware_vCenter_Log_Insight.gateway.Value = Read-Host "Gateway"
   $ovfConfiguration.vami.VMware_vCenter_Log_Insight.hostname.Value = Read-Host "Hostname"
   $ovfConfiguration.vami.VMware_vCenter_Log_Insight.DNS.Value = Read-Host "DNS Servers - Comma seperated, no spaces"
   $ovfConfiguration.vm.rootpw.Value = Read-Host "Password"
   $(Get-ResourcePool).Name
   $resourcepool = Read-Host "Resource Pool"
   $(Get-VMhost).Name
   $vmhost = Read-Host "VM host"
   $(Get-Datastore).Name
   $datastore = Read-Host "Datastore"

   Write-Host "Please Review the configuration options"
   $ovfConfiguration.ToHashTable() | fl
   Write-Host "Resource Pool - $resourcepool"
   Write-Host "VM Host - $vmhost"
   Write-Host "Datastore - $datastore"
   $continueflag = Read-Host "Is this correct? `'y`' for yes `'n`' for no"
}

Import-VApp -Source $path -OvfConfiguration $ovfConfiguration -Name $name -Location $resourcepool -VMHost $vmhost -Datastore $datastore
1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *