diff --git a/changelogs/fragments/9066-proxmox-kvm-ciupgrade.yml b/changelogs/fragments/9066-proxmox-kvm-ciupgrade.yml new file mode 100644 index 0000000000..91e9127b70 --- /dev/null +++ b/changelogs/fragments/9066-proxmox-kvm-ciupgrade.yml @@ -0,0 +1,2 @@ +minor_changes: + - proxmox_kvm - adds the ``ciupgrade`` parameter to specify whether cloud-init should upgrade system packages at first boot (https://github.com/ansible-collections/community.general/pull/9066). diff --git a/plugins/modules/proxmox_kvm.py b/plugins/modules/proxmox_kvm.py index cac3496228..0c9904873d 100644 --- a/plugins/modules/proxmox_kvm.py +++ b/plugins/modules/proxmox_kvm.py @@ -86,6 +86,11 @@ options: type: str choices: ['nocloud', 'configdrive2'] version_added: 1.3.0 + ciupgrade: + description: + - 'cloud-init: do an automatic package upgrade after the first boot.' + type: bool + version_added: 10.0.0 ciuser: description: - 'cloud-init: username of default user to create.' @@ -984,6 +989,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible): # Available only in PVE 4 only_v4 = ['force', 'protection', 'skiplock'] only_v6 = ['ciuser', 'cipassword', 'sshkeys', 'ipconfig', 'tags'] + only_v8 = ['ciupgrade'] # valid clone parameters valid_clone_params = ['format', 'full', 'pool', 'snapname', 'storage', 'target'] @@ -1012,6 +1018,12 @@ class ProxmoxKvmAnsible(ProxmoxAnsible): if p in kwargs: del kwargs[p] + # The features work only on PVE 8 + if pve_major_version < 8: + for p in only_v8: + if p in kwargs: + del kwargs[p] + # 'sshkeys' param expects an urlencoded string if 'sshkeys' in kwargs: urlencoded_ssh_keys = quote(kwargs['sshkeys'], safe='') @@ -1207,6 +1219,7 @@ def main(): cicustom=dict(type='str'), cipassword=dict(type='str', no_log=True), citype=dict(type='str', choices=['nocloud', 'configdrive2']), + ciupgrade=dict(type='bool'), ciuser=dict(type='str'), clone=dict(type='str'), cores=dict(type='int'), @@ -1414,6 +1427,7 @@ def main(): cicustom=module.params['cicustom'], cipassword=module.params['cipassword'], citype=module.params['citype'], + ciupgrade=module.params['ciupgrade'], ciuser=module.params['ciuser'], cpulimit=module.params['cpulimit'], cpuunits=module.params['cpuunits'],