mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vsphere_guest: Set extra config and powerstate after template deploy (#4266)
* Fixes #1381 * Fixes #2971 * Fixes #3056
This commit is contained in:
parent
5e1dfa9485
commit
37008e1da1
1 changed files with 13 additions and 1 deletions
|
@ -733,7 +733,7 @@ def deploy_template(vsphere_client, guest, resource_pool, template_src, esxi, mo
|
|||
|
||||
try:
|
||||
if not vmTarget:
|
||||
cloneArgs = dict(resourcepool=rpmor, power_on=power_on_after_clone)
|
||||
cloneArgs = dict(resourcepool=rpmor, power_on=False)
|
||||
|
||||
if snapshot_to_clone is not None:
|
||||
#check if snapshot_to_clone is specified, Create a Linked Clone instead of a full clone.
|
||||
|
@ -745,6 +745,18 @@ def deploy_template(vsphere_client, guest, resource_pool, template_src, esxi, mo
|
|||
cloneArgs["folder"] = vm_extra_config.get("folder")
|
||||
|
||||
vmTemplate.clone(guest, **cloneArgs)
|
||||
|
||||
vm = vsphere_client.get_vm_by_name(guest)
|
||||
|
||||
# VM was created. If there is any extra config options specified, set
|
||||
if vm_extra_config:
|
||||
vm.set_extra_config(vm_extra_config)
|
||||
|
||||
# Power on if asked
|
||||
if power_on_after_clone == True:
|
||||
state = 'powered_on'
|
||||
power_state(vm, state, True)
|
||||
|
||||
changed = True
|
||||
else:
|
||||
changed = False
|
||||
|
|
Loading…
Reference in a new issue