mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
proxmox_kvm: allow force to be use with state=absent (#849)
In this case a running VM will be automaticaly shut down before being removed. With updates from Andrew Klychkov <aaklychkov@mail.ru>.
This commit is contained in:
parent
73f8338980
commit
e20eb64c6e
2 changed files with 8 additions and 2 deletions
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
breaking_changes:
|
||||
- proxmox_kvm - recognize ``force=yes`` in conjunction with ``state=absent`` to forcibly remove a running VM (https://github.com/ansible-collections/community.general/pull/849).
|
|
@ -113,7 +113,7 @@ options:
|
|||
force:
|
||||
description:
|
||||
- Allow to force stop VM.
|
||||
- Can be used with states C(stopped) and C(restarted).
|
||||
- Can be used with states C(stopped), C(restarted) and C(absent).
|
||||
default: no
|
||||
type: bool
|
||||
format:
|
||||
|
@ -1156,7 +1156,10 @@ def main():
|
|||
module.exit_json(changed=False)
|
||||
|
||||
if getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE)(vmid).status.current.get()['status'] == 'running':
|
||||
module.exit_json(changed=False, msg="VM %s is running. Stop it before deletion." % vmid)
|
||||
if module.params['force']:
|
||||
stop_vm(module, proxmox, vm, vmid, timeout, True)
|
||||
else:
|
||||
module.exit_json(changed=False, msg="VM %s is running. Stop it before deletion or use force=yes." % vmid)
|
||||
|
||||
taskid = getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE).delete(vmid)
|
||||
while timeout:
|
||||
|
|
Loading…
Reference in a new issue