From 0bfebde5c942ed0fbba42e3db7e94cbef8393d9b Mon Sep 17 00:00:00 2001 From: aaronjohnleonard Date: Mon, 1 Jan 2024 06:30:28 -0700 Subject: [PATCH] proxmox_kvm - state:template will check if template exists first (#7791) (#7792) * proxmox_kvm - state:template will check if template exists first (#7791) * added changelog entry * Update changelog fragment. --------- Co-authored-by: Felix Fontein --- ...791-proxmox_kvm-state-template-will-check-status-first.yaml | 2 ++ plugins/modules/proxmox_kvm.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/7791-proxmox_kvm-state-template-will-check-status-first.yaml diff --git a/changelogs/fragments/7791-proxmox_kvm-state-template-will-check-status-first.yaml b/changelogs/fragments/7791-proxmox_kvm-state-template-will-check-status-first.yaml new file mode 100644 index 0000000000..1e061ce6af --- /dev/null +++ b/changelogs/fragments/7791-proxmox_kvm-state-template-will-check-status-first.yaml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_kvm - running ``state=template`` will first check whether VM is already a template (https://github.com/ansible-collections/community.general/pull/7792). diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 7460f9bbfe..c0133ed870 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -1556,6 +1556,9 @@ def main(): try: vm = proxmox.get_vm(vmid) + if vm['template'] == 1: + module.exit_json(changed=False, vmid=vmid, msg="VM %s is already a template" % vmid, **status) + if proxmox.convert_to_template(vm, force=module.params['force'], timeout=module.params['timeout']): module.exit_json(changed=True, vmid=vmid, msg="VM %s is converting to template" % vmid, **status) except Exception as e: