diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index 56f4fdabc2b..bfc0547ca7d 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -83,7 +83,8 @@ options: description: - Manage some VM hardware attributes. - 'Valid attributes are:' - - ' - C(hotadd_cpu) (boolean): Allow cpus to be added while the VM is running.' + - ' - C(hotadd_cpu) (boolean): Allow virtual CPUs to be added while the VM is running.' + - ' - C(hotremove_cpu) (boolean): Allow virtual CPUs to be removed while the VM is running. version_added: 2.5' - ' - C(hotadd_memory) (boolean): Allow memory to be added while the VM is running.' - ' - C(memory_mb) (integer): Amount of memory in MB.' - ' - C(nested_virt) (bool): Enable nested virtualization. version_added: 2.5' @@ -232,6 +233,9 @@ EXAMPLES = r''' memory_reservation: 512 memory_reservation_lock: True max_connections: 5 + hotadd_cpu: True + hotremove_cpu: True + hotadd_memory: False cdrom: type: iso iso_path: "[datastore1] livecd.iso" @@ -670,6 +674,11 @@ class PyVmomiHelper(PyVmomi): if vm_obj is None or self.configspec.cpuHotAddEnabled != vm_obj.config.cpuHotAddEnabled: self.change_detected = True + if 'hotremove_cpu' in self.params['hardware']: + self.configspec.cpuHotRemoveEnabled = bool(self.params['hardware']['hotremove_cpu']) + if vm_obj is None or self.configspec.cpuHotRemoveEnabled != vm_obj.config.cpuHotRemoveEnabled: + self.change_detected = True + if 'memory_reservation' in self.params['hardware']: memory_reservation_mb = 0 try: diff --git a/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml b/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml index 25a008ddf8f..deb31f95902 100644 --- a/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml +++ b/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml @@ -51,6 +51,7 @@ # memory_reservation: 512 # memory_reservation_lock: False # nested_virt: True + # hotremove_cpu: True max_connections: 10 disk: - size: 0gb