Hi All,
We have multiple DataCenter with atleast 5 Clusters each.
When ever we are updating templates with security patches etc., we need to clone the same template across all the clusters.
We have some naming structure, before cloning we need to cross check with naming convention and initiate the clone and which is a tedious task.
Ex:
Datacenter1 -> Cluster1
-> Cluster2
-> Cluster3
-> Cluster4
-> Cluster5
-> Cluster6
Cluster1 -> Win_Tmpl_V1 -> Patches and other stuff is updated in this template located in cluster1
Now we would like to deploy the same template across all the clusters as below.
Cluster2 -> Win_TMPL_V1_1
Cluster3 -> Win_TMPL_V1_2
Cluster4 -> Win_TMPL_V1_3
Cluster5 -> Win_TMPL_V1_4
Cluster6 -> Win_TMPL_V1_5
So before cloning it has to check whether this template is available or not and accordingly it has to increment the number and clone for entire clusters across datacenters.
Please do let us know is there any way to automate this thing.
Regards,
RAM
It doesn't directly answer your question BUT.... If the template is exactly the same on every cluster with the only difference being the name, why not just use Content libraries accessible to all clusters so you only have to update the file once without having to manually clone it every time?
It has been already proposed to customer, but customer wants to go through the process as I mentioned.
Yes, that can be automated.
But a few questions first.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
1) Template name is provided in the Script
2) Template should be replicated to all Clusters across the Datacenters in a single vCenter
3) Win_TMPL_V1 will be the template name, While cloning to other clusters it has to be Win_TMPL_V1_1. It means only the last number should be added up and it should not be like Win_TMPL_V2
4) Suffix number is not linked to cluster any way. We need to ensure same template is rolled out in all the clusters. There is no specific requirement that the replication has to be in alphabetical sequential.
One more question, a Template is not linked to a Cluster but to a Datacenter.
To make sure, you want multiple Templates in a Datacenter, one for each Cluster in that Datacenter?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes Luc, Correct
There is a known issue with the New-Template cmdlet, that's why I reverted to the API method.
Try something like this
$template = Get-Template -Name $srcName
$index = 1
Get-Datacenter -PipelineVariable dc | Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
$spec = New-Object VMware.Vim.VirtualMachineCloneSpec
$spec.Location = New-Object VMware.Vim.VirtualMachineRelocateSpec
$spec.Location.Datastore = (Get-Datastore -RelatedObject $cluster |
where{$_.ExtensionData.Summary.MultipleHostAccess} | Get-Random).ExtensionData.MoRef
$spec.Location.Folder = $dc.ExtensionData.VmFolder
$spec.Location.Host = $cluster.ExtensionData.Host | Get-Random
$spec.Location.Pool = $cluster.ExtensionData.ResourcePool
$template.ExtensionData.CloneVM($dc.ExtensionData.VMFolder, "$($srcName)_$($index)", $spec)
$index++
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference