|
345 | 345 | description:
|
346 | 346 | - Enable/disable the protection flag of the VM. This will enable/disable the remove VM and remove disk operations.
|
347 | 347 | 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 |
348 | 354 | reboot:
|
349 | 355 | description:
|
350 | 356 | - Allow reboot. If set to V(true), the VM exit on reboot.
|
@@ -1273,6 +1279,7 @@ def main():
|
1273 | 1279 | parallel=dict(type='dict'),
|
1274 | 1280 | pool=dict(type='str'),
|
1275 | 1281 | protection=dict(type='bool'),
|
| 1282 | + purge=dict(type='bool', default=False), |
1276 | 1283 | reboot=dict(type='bool'),
|
1277 | 1284 | revert=dict(type='str'),
|
1278 | 1285 | rng0=dict(type='str'),
|
@@ -1589,7 +1596,11 @@ def main():
|
1589 | 1596 | proxmox.stop_vm(vm, True, timeout=module.params['timeout'])
|
1590 | 1597 | else:
|
1591 | 1598 | 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) |
1593 | 1604 | if not proxmox.wait_for_task(vm['node'], taskid):
|
1594 | 1605 | module.fail_json(msg='Reached timeout while waiting for removing VM. Last line in task before timeout: %s' %
|
1595 | 1606 | proxmox_node.tasks(taskid).log.get()[:1])
|
|
0 commit comments