Skip to content

Commit 836567a

Browse files
authored
feature: add new purge parameter to proxmox_kvm module (#148)
* feature: add new purge parameter to proxmox_kvm module * add changelog fragment
1 parent 3bbc064 commit 836567a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- proxmox_kvm - add new purge parameter to proxmox_kvm module (https://github.com/ansible-collections/community.proxmox/issues/60, https://github.com/ansible-collections/community.proxmox/pull/148).

plugins/modules/proxmox_kvm.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@
345345
description:
346346
- Enable/disable the protection flag of the VM. This will enable/disable the remove VM and remove disk operations.
347347
type: bool
348+
purge:
349+
description:
350+
- Remove VMID from configurations, like backup & replication jobs and HA.
351+
- Used with state C(absent).
352+
type: bool
353+
default: false
348354
reboot:
349355
description:
350356
- Allow reboot. If set to V(true), the VM exit on reboot.
@@ -1273,6 +1279,7 @@ def main():
12731279
parallel=dict(type='dict'),
12741280
pool=dict(type='str'),
12751281
protection=dict(type='bool'),
1282+
purge=dict(type='bool', default=False),
12761283
reboot=dict(type='bool'),
12771284
revert=dict(type='str'),
12781285
rng0=dict(type='str'),
@@ -1589,7 +1596,11 @@ def main():
15891596
proxmox.stop_vm(vm, True, timeout=module.params['timeout'])
15901597
else:
15911598
module.exit_json(changed=False, vmid=vmid, msg="VM %s is running. Stop it before deletion or use force=true." % vmid)
1592-
taskid = proxmox_node.qemu.delete(vmid)
1599+
1600+
delete_params = {}
1601+
if module.params['purge']:
1602+
delete_params['purge'] = 1
1603+
taskid = proxmox_node.qemu.delete(vmid, **delete_params)
15931604
if not proxmox.wait_for_task(vm['node'], taskid):
15941605
module.fail_json(msg='Reached timeout while waiting for removing VM. Last line in task before timeout: %s' %
15951606
proxmox_node.tasks(taskid).log.get()[:1])

0 commit comments

Comments
 (0)