From 7609a8cdd622311f6bc8441af36004d6a4cd62dd Mon Sep 17 00:00:00 2001 From: Yuwei Zhou Date: Fri, 14 Dec 2018 16:48:40 +0800 Subject: [PATCH] support overprovision in azure_rm_vmss (#49806) --- .../azure/azure_rm_virtualmachine_scaleset.py | 16 +++++++++++++++- .../azure_rm_virtualmachine_scaleset_facts.py | 6 ++++++ .../tasks/main.yml | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py index 2c11f44508..d0205ca826 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset.py @@ -197,6 +197,12 @@ options: version_added: "2.7" aliases: - security_group_name + overprovision: + description: + - Specifies whether the Virtual Machine Scale Set should be overprovisioned. + type: bool + default: True + version_added: "2.8" extends_documentation_fragment: - azure @@ -403,7 +409,8 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): virtual_network_name=dict(type='str', aliases=['virtual_network']), remove_on_absent=dict(type='list', default=['all']), enable_accelerated_networking=dict(type='bool'), - security_group=dict(type='raw', aliases=['security_group_name']) + security_group=dict(type='raw', aliases=['security_group_name']), + overprovision=dict(type='bool', default=True) ) self.resource_group = None @@ -432,6 +439,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): self.load_balancer = None self.enable_accelerated_networking = None self.security_group = None + self.overprovision = None self.results = dict( changed=False, @@ -570,6 +578,10 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): differences.append('Tags') changed = True + if bool(self.overprovision) != bool(vmss_dict['properties']['overprovision']): + differences.append('overprovision') + changed = True + self.differences = differences elif self.state == 'absent': @@ -638,6 +650,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): vmss_resource = self.compute_models.VirtualMachineScaleSet( location=self.location, + overprovision=self.overprovision, tags=self.tags, upgrade_policy=self.compute_models.UpgradePolicy( mode=self.upgrade_policy @@ -731,6 +744,7 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase): vmss_resource = self.get_vmss() vmss_resource.virtual_machine_profile.storage_profile.os_disk.caching = self.os_disk_caching vmss_resource.sku.capacity = self.capacity + vmss_resource.overprovision = self.overprovision if self.data_disks is not None: data_disks = [] diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py index 596bd486e3..5b6bce4490 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine_scaleset_facts.py @@ -182,6 +182,11 @@ vmss: type: str returned: always sample: Linux + overprovision: + description: + - Specifies whether the Virtual Machine Scale Set should be overprovisioned. + type: bool + sample: true resource_group: description: - Resource group. @@ -348,6 +353,7 @@ class AzureRMVirtualMachineScaleSetFacts(AzureRMModuleBase): 'image': vmss['properties']['virtualMachineProfile']['storageProfile']['imageReference'], 'os_disk_caching': vmss['properties']['virtualMachineProfile']['storageProfile']['osDisk']['caching'], 'os_type': 'Linux' if (vmss['properties']['virtualMachineProfile']['osProfile'].get('linuxConfiguration') is not None) else 'Windows', + 'overprovision': vmss['properties']['overprovision'], 'managed_disk_type': vmss['properties']['virtualMachineProfile']['storageProfile']['osDisk']['managedDisk']['storageAccountType'], 'data_disks': data_disks, 'virtual_network_name': virtual_network_name, diff --git a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml b/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml index 77dd8eba05..d6dc0d8872 100644 --- a/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml +++ b/test/integration/targets/azure_rm_virtualmachine_scaleset/tasks/main.yml @@ -215,6 +215,7 @@ os_disk_caching: "{{ body.os_disk_caching }}" image: "{{ body.image }}" data_disks: "{{ body.data_disks }}" + overprovision: "{{ body.overprovision }}" register: results - name: Assert that nothing was changed