mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #6914/17b4219b backport][stable-7] proxmox_kvm: enable 'force' restart of vm (as documented) (#6997)
proxmox_kvm: enable 'force' restart of vm (as documented) (#6914)
* enable 'force' restart of vm
* added changelog fragment
* Update changelogs/fragments/6914-proxmox_kvm-enable-force-restart.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 17b4219b8b
)
Co-authored-by: Jeff Turner <jeff@torusoft.com>
This commit is contained in:
parent
fb3768aada
commit
7d68af57af
2 changed files with 5 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- proxmox_kvm - enabled force restart of VM, bringing the ``force`` parameter functionality in line with what is described in the docs (https://github.com/ansible-collections/community.general/pull/6914).
|
|
@ -1111,11 +1111,11 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def restart_vm(self, vm, **status):
|
def restart_vm(self, vm, force, **status):
|
||||||
vmid = vm['vmid']
|
vmid = vm['vmid']
|
||||||
try:
|
try:
|
||||||
proxmox_node = self.proxmox_api.nodes(vm['node'])
|
proxmox_node = self.proxmox_api.nodes(vm['node'])
|
||||||
taskid = proxmox_node.qemu(vmid).status.reboot.post()
|
taskid = proxmox_node.qemu(vmid).status.reset.post() if force else proxmox_node.qemu(vmid).status.reboot.post()
|
||||||
if not self.wait_for_task(vm['node'], taskid):
|
if not self.wait_for_task(vm['node'], taskid):
|
||||||
self.module.fail_json(msg='Reached timeout while waiting for rebooting VM. Last line in task before timeout: %s' %
|
self.module.fail_json(msg='Reached timeout while waiting for rebooting VM. Last line in task before timeout: %s' %
|
||||||
proxmox_node.tasks(taskid).log.get()[:1])
|
proxmox_node.tasks(taskid).log.get()[:1])
|
||||||
|
@ -1493,7 +1493,7 @@ def main():
|
||||||
if vm['status'] == 'stopped':
|
if vm['status'] == 'stopped':
|
||||||
module.exit_json(changed=False, vmid=vmid, msg="VM %s is not running" % vmid, **status)
|
module.exit_json(changed=False, vmid=vmid, msg="VM %s is not running" % vmid, **status)
|
||||||
|
|
||||||
if proxmox.restart_vm(vm):
|
if proxmox.restart_vm(vm, force=module.params['force']):
|
||||||
module.exit_json(changed=True, vmid=vmid, msg="VM %s is restarted" % vmid, **status)
|
module.exit_json(changed=True, vmid=vmid, msg="VM %s is restarted" % vmid, **status)
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
|
|
Loading…
Reference in a new issue