Hi
I have a playbook that creates multiple VM’s in VMware (see below).
When the VM’s have all been created they have the same server name as the template. So I have 20 new VM’s all with the same OS name.
I want the OS server name to be changed to the same name as the Vm host name that the Ansible playbook gives it when it runs. Is there any way of doing this? It’s obviously pointless creating multiple servers all with the same name.
I can easily do this using VMware PowerCLI and associating a VMware Customization Spec to the VM template:
$esxName = “172.22.22.22”
$template = “WIN2012R2-TEMPLATE”
$datastore = “IE-VMFS5-32”
$newVmList = “DR-EA05”, “DR-EA06”
$custSpec = “Spectest”
$location = “Alphanew”
$taskTab = @{}
Create all the VMs specified in $newVmList
foreach($Name in $newVmList) {
$taskTab[(New-VM -Name $Name -VMHost (Get-VMHost -Name $esxName) -Template $template -Datastore $datastore -OSCustomizationSpec $custSpec -Location $location -RunAsync).Id] = $Name
}
Is there anyway of adding a VMware Customization spec to the Ansible playbook? Or any other way than you can think of that I can use to set the new VM’s server name?
Playbook: