From 861f55eb049fcc0b20cc647d31d71a09a65f1818 Mon Sep 17 00:00:00 2001 From: rippleFCL Date: Mon, 20 May 2024 07:30:59 +0100 Subject: [PATCH] added usb support to proxmox module (#8199) * added usb support to proxmox module * forgot docs * fixed net refrances * changed usb to USB * added changelog fragment Co-authored-by: Felix Fontein * added changelog fragment * corrected spelling and punctuation Co-authored-by: Felix Fontein * Another one. --------- Co-authored-by: ripplefcl Co-authored-by: Felix Fontein --- .../8199-added-usb-support-to-proxmox-module.yml | 2 ++ plugins/modules/proxmox_kvm.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8199-added-usb-support-to-proxmox-module.yml diff --git a/changelogs/fragments/8199-added-usb-support-to-proxmox-module.yml b/changelogs/fragments/8199-added-usb-support-to-proxmox-module.yml new file mode 100644 index 0000000000..b621fe284c --- /dev/null +++ b/changelogs/fragments/8199-added-usb-support-to-proxmox-module.yml @@ -0,0 +1,2 @@ +minor_changes: + - "proxmox_kvm - adds``usb`` parameter for setting USB devices on proxmox KVM VMs (https://github.com/ansible-collections/community.general/pull/8199)." diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index 253a75d4b3..9fe805c7ab 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -519,6 +519,16 @@ options: default: '2.0' type: dict version_added: 7.1.0 + usb: + description: + - A hash/dictionary of USB devices for the VM. O(usb='{"key":"value", "key":"value"}'). + - Keys allowed are - C(usb[n]) where 0 ≤ n ≤ N. + - Values allowed are - C(host="value|spice",mapping="value",usb3="1|0"). + - host is either C(spice) or the USB id/port. + - Option C(mapping) is the mapped USB device name. + - Option C(usb3) enables USB 3 support. + type: dict + version_added: 9.0.0 update: description: - If V(true), the VM will be updated with new value. @@ -1094,7 +1104,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible): ) # Convert all dict in kwargs to elements. - # For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n], ipconfig[n] + # For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n], ipconfig[n], usb[n] for k in list(kwargs.keys()): if isinstance(kwargs[k], dict): kwargs.update(kwargs[k]) @@ -1311,6 +1321,7 @@ def main(): storage=dict(type='str', required=True), version=dict(type='str', choices=['2.0', '1.2'], default='2.0') )), + usb=dict(type='dict'), update=dict(type='bool', default=False), update_unsafe=dict(type='bool', default=False), vcpus=dict(type='int'), @@ -1516,6 +1527,7 @@ def main(): tdf=module.params['tdf'], template=module.params['template'], tpmstate0=module.params['tpmstate0'], + usb=module.params['usb'], vcpus=module.params['vcpus'], vga=module.params['vga'], virtio=module.params['virtio'],