Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #6159/7059789f backport][stable-6] Add archive param for proxmox_kvm module #6235

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/6158-create-proxmox-vm-from-archive.yml
Original file line number Diff line number Diff line change
@@ -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)."
15 changes: 15 additions & 0 deletions plugins/modules/proxmox_kvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
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.
Expand Down Expand Up @@ -536,6 +541,14 @@
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
Expand Down Expand Up @@ -1053,6 +1066,7 @@ def stop_vm(self, vm, force):
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'),
Expand Down Expand Up @@ -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'],
Expand Down