mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixed incorrect VMID: cloning to an existing VM (#3266)
* Fixed incorrect VMID: cloning to an existing VM During a cloning operation, if the destination VM already exists the VMID returned is not correct. The VMID returned should be that of the destination VM and not that of the source VM (consistent with line 1230). A playbook that relies on the returned VMID, for example, to perform other operations on the destination VM, will not work properly if it is unexpectedly interrupted. * Add files via upload * moved 3266-vmid-existing-target-clone.yml to changelogs/fragments/ replaced line separator CRLF -> LF * storing vmid list in variable to avoid multiple API calls
This commit is contained in:
parent
e77adff0b7
commit
4e2d4e3c68
2 changed files with 6 additions and 2 deletions
3
changelogs/fragments/3266-vmid-existing-target-clone.yml
Normal file
3
changelogs/fragments/3266-vmid-existing-target-clone.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
bugfixes:
|
||||
- proxmox_kvm - clone operation should return the VMID of the target VM and not that of the source VM.
|
||||
This was failing when the target VM with the chosen name already existed (https://github.com/ansible-collections/community.general/pull/3266).
|
|
@ -1201,8 +1201,9 @@ def main():
|
|||
module.fail_json(vmid=vmid, msg='VM with vmid = %s does not exist in cluster' % vmid)
|
||||
|
||||
# Ensure the choosen VM name doesn't already exist when cloning
|
||||
if get_vmid(proxmox, name):
|
||||
module.exit_json(changed=False, vmid=vmid, msg="VM with name <%s> already exists" % name)
|
||||
existing_vmid = get_vmid(proxmox, name)
|
||||
if existing_vmid:
|
||||
module.exit_json(changed=False, vmid=existing_vmid[0], msg="VM with name <%s> already exists" % name)
|
||||
|
||||
# Ensure the choosen VM id doesn't already exist when cloning
|
||||
if get_vm(proxmox, newid):
|
||||
|
|
Loading…
Reference in a new issue