1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

proxmox_kvm: support for tpmstate0 parameter (#6533)

* proxmox_kvm: added support for tmpstate

adds hash of options for a TPM state disk, which is required for Windows 11 installations

* updated wrong version in docs

* bump version 7.1.0 -> 7.1.1

* fixed parameter name typo

* updated to pass sanity; assumed version_added to be next major (7.2.0)

* replaced 'tpmstate' with 'tpmstate0'; added suboptions to kvm_args

* fixed line too long

* use get() instead of pop() to preserve verbose invocation.module_args

* update comment to include tpmstate0

* added changelog fragment

* Revert "bump version 7.1.0 -> 7.1.1"

This reverts commit 772ed98dba.

* Include PR link in changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Corrected version_added

Co-authored-by: Felix Fontein <felix@fontein.de>

* corrected semantic markup for option name

Co-authored-by: Felix Fontein <felix@fontein.de>

* set suboptions of tpmstate0 to required

* set default for tpmstate0.version (2.0)

* fixed typo

Co-authored-by: Felix Fontein <felix@fontein.de>

* wrapped default version string in quotes

Co-authored-by: Felix Fontein <felix@fontein.de>

* Improve changelog formatting.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Jeff Turner 2023-05-29 13:56:57 -03:00 committed by GitHub
parent b133aa40c6
commit 01f21b1d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- proxmox_kvm - added support for ``tpmstate0`` parameter to configure TPM (Trusted Platform Module) disk. TPM is required for Windows 11 installations (https://github.com/ansible-collections/community.general/pull/6533).

View file

@ -483,6 +483,24 @@ options:
- When used with I(state=stopped) the option sets a graceful timeout for VM stop after which a VM will be forcefully stopped.
type: int
default: 30
tpmstate0:
description:
- A hash/dictionary of options for the Trusted Platform Module disk.
- A TPM state disk is required for Windows 11 installations.
suboptions:
storage:
description:
- O(tpmstate0.storage) is the storage identifier where to create the disk.
type: str
required: true
version:
description:
- The TPM version to use.
type: str
choices: ['1.2', '2.0']
default: '2.0'
type: dict
version_added: 7.1.0
update:
description:
- If C(true), the VM will be updated with new value.
@ -942,7 +960,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
urlencoded_ssh_keys = quote(kwargs['sshkeys'], safe='')
kwargs['sshkeys'] = str(urlencoded_ssh_keys)
# If update, don't update disk (virtio, efidisk0, ide, sata, scsi) and network interface
# If update, don't update disk (virtio, efidisk0, tpmstate0, ide, sata, scsi) and network interface
# pool parameter not supported by qemu/<vmid>/config endpoint on "update" (PVE 6.2) - only with "create"
if update:
if 'virtio' in kwargs:
@ -955,6 +973,8 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
del kwargs['ide']
if 'efidisk0' in kwargs:
del kwargs['efidisk0']
if 'tpmstate0' in kwargs:
del kwargs['tpmstate0']
if 'net' in kwargs:
del kwargs['net']
if 'force' in kwargs:
@ -982,6 +1002,13 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
if 'storage' != k])
kwargs['efidisk0'] = efidisk0_str
# Flatten tpmstate0 option to a string so that it's a string which is what Proxmoxer and the API expect
if 'tpmstate0' in kwargs:
kwargs['tpmstate0'] = '{storage}:1,version=v{version}'.format(
storage=kwargs['tpmstate0'].get('storage'),
version=kwargs['tpmstate0'].get('version')
)
# 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 k in list(kwargs.keys()):
@ -1167,6 +1194,11 @@ def main():
tdf=dict(type='bool'),
template=dict(type='bool'),
timeout=dict(type='int', default=30),
tpmstate0=dict(type='dict',
options=dict(
storage=dict(type='str', required=True),
version=dict(type='str', choices=['2.0', '1.2'], default='2.0')
)),
update=dict(type='bool', default=False),
vcpus=dict(type='int'),
vga=dict(choices=['std', 'cirrus', 'vmware', 'qxl', 'serial0', 'serial1', 'serial2', 'serial3', 'qxl2', 'qxl3', 'qxl4']),
@ -1360,6 +1392,7 @@ def main():
target=module.params['target'],
tdf=module.params['tdf'],
template=module.params['template'],
tpmstate0=module.params['tpmstate0'],
vcpus=module.params['vcpus'],
vga=module.params['vga'],
virtio=module.params['virtio'],