1
0
Fork 0
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) (#3282)

* 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

(cherry picked from commit 4e2d4e3c68)

Co-authored-by: Atlas974 <43972908+Atlas974@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-08-27 19:09:37 +02:00 committed by GitHub
parent 14d663029a
commit f3375c638e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View 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).

View file

@ -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):