mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* added purge as optional module parameter
* Adding changelog fragment
* Adding version to documentation for purge
Co-authored-by: Felix Fontein <felix@fontein.de>
* Updating changelog
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 79fb3e9852
)
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
parent
d721283846
commit
ef7ade6a56
2 changed files with 20 additions and 1 deletions
3
changelogs/fragments/2013-proxmox-purge-parameter.yml
Normal file
3
changelogs/fragments/2013-proxmox-purge-parameter.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- proxmox - added ``purge`` module parameter for use when deleting lxc's with HA options (https://github.com/ansible-collections/community.general/pull/2013).
|
|
@ -123,6 +123,15 @@ options:
|
||||||
- with states C(stopped) , C(restarted) allow to force stop instance
|
- with states C(stopped) , C(restarted) allow to force stop instance
|
||||||
type: bool
|
type: bool
|
||||||
default: 'no'
|
default: 'no'
|
||||||
|
purge:
|
||||||
|
description:
|
||||||
|
- Remove container from all related configurations.
|
||||||
|
- For example backup jobs, replication jobs, or HA.
|
||||||
|
- Related ACLs and Firewall entries will always be removed.
|
||||||
|
- Used with state C(absent).
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 2.3.0
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Indicate desired state of the instance
|
- Indicate desired state of the instance
|
||||||
|
@ -506,6 +515,7 @@ def main():
|
||||||
searchdomain=dict(),
|
searchdomain=dict(),
|
||||||
timeout=dict(type='int', default=30),
|
timeout=dict(type='int', default=30),
|
||||||
force=dict(type='bool', default=False),
|
force=dict(type='bool', default=False),
|
||||||
|
purge=dict(type='bool', default=False),
|
||||||
state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']),
|
state=dict(default='present', choices=['present', 'absent', 'stopped', 'started', 'restarted']),
|
||||||
pubkey=dict(type='str', default=None),
|
pubkey=dict(type='str', default=None),
|
||||||
unprivileged=dict(type='bool', default=False),
|
unprivileged=dict(type='bool', default=False),
|
||||||
|
@ -686,7 +696,13 @@ def main():
|
||||||
if getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE)(vmid).status.current.get()['status'] == 'mounted':
|
if getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE)(vmid).status.current.get()['status'] == 'mounted':
|
||||||
module.exit_json(changed=False, msg="VM %s is mounted. Stop it with force option before deletion." % vmid)
|
module.exit_json(changed=False, msg="VM %s is mounted. Stop it with force option before deletion." % vmid)
|
||||||
|
|
||||||
taskid = getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE).delete(vmid)
|
delete_params = {}
|
||||||
|
|
||||||
|
if module.params['purge']:
|
||||||
|
delete_params['purge'] = 1
|
||||||
|
|
||||||
|
taskid = getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE).delete(vmid, **delete_params)
|
||||||
|
|
||||||
while timeout:
|
while timeout:
|
||||||
if (proxmox.nodes(vm[0]['node']).tasks(taskid).status.get()['status'] == 'stopped' and
|
if (proxmox.nodes(vm[0]['node']).tasks(taskid).status.get()['status'] == 'stopped' and
|
||||||
proxmox.nodes(vm[0]['node']).tasks(taskid).status.get()['exitstatus'] == 'OK'):
|
proxmox.nodes(vm[0]['node']).tasks(taskid).status.get()['exitstatus'] == 'OK'):
|
||||||
|
|
Loading…
Reference in a new issue