From 1d36db18066bab2f3a7e81866be5398282f1d004 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 25 Mar 2023 08:50:37 +0100 Subject: [PATCH] [PR #6159/7059789f backport][stable-6] Add archive param for proxmox_kvm module (#6235) Add archive param for proxmox_kvm module (#6159) We simply add a param to allow proxmox administrator to restore VM from an archives. This new option will be useful to automate automatic creation and restore of VM. Co-authored-by: Julian Vanden Broeck (cherry picked from commit 7059789f35edf25cc71d788fa87525489c009002) Co-authored-by: Julian <374571+l00ptr@users.noreply.github.com> --- .../6158-create-proxmox-vm-from-archive.yml | 2 ++ plugins/modules/proxmox_kvm.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 changelogs/fragments/6158-create-proxmox-vm-from-archive.yml diff --git a/changelogs/fragments/6158-create-proxmox-vm-from-archive.yml b/changelogs/fragments/6158-create-proxmox-vm-from-archive.yml new file mode 100644 index 0000000000..2c66110792 --- /dev/null +++ b/changelogs/fragments/6158-create-proxmox-vm-from-archive.yml @@ -0,0 +1,2 @@ +minor_changes: + - "proxmox_kvm - add new ``archive`` parameter. This is needed to create a VM from an archive (backup) (https://github.com/ansible-collections/community.general/pull/6159)." diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 852f6333b7..fe55470443 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -22,6 +22,11 @@ attributes: diff_mode: support: none options: + archive: + description: + - Specify a path to an archive to restore (instead of creating or cloning a VM). + type: str + version_added: 6.5.0 acpi: description: - Specify if ACPI should be enabled/disabled. @@ -536,6 +541,14 @@ EXAMPLES = ''' name: spynal node: sabrewulf +- name: Create a VM from archive (backup) + community.general.proxmox_kvm: + api_user: root@pam + api_password: secret + api_host: helldorado + archive: backup-storage:backup/vm/140/2023-03-08T06:41:23Z + name: spynal + - name: Create new VM with minimal options and given vmid community.general.proxmox_kvm: api_user: root@pam @@ -1053,6 +1066,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible): def main(): module_args = proxmox_auth_argument_spec() kvm_args = dict( + archive=dict(type='str'), acpi=dict(type='bool'), agent=dict(type='str'), args=dict(type='str'), @@ -1256,6 +1270,7 @@ def main(): module.fail_json(msg="node '%s' does not exist in cluster" % node) proxmox.create_vm(vmid, newid, node, name, memory, cpu, cores, sockets, update, + archive=module.params['archive'], acpi=module.params['acpi'], agent=module.params['agent'], autostart=module.params['autostart'],