Fixing upgrade_policy idempotence (#38022)

This commit is contained in:
Zim Kalinowski 2018-08-14 13:24:34 +08:00 committed by Yunge Zhu
parent 43ae240431
commit ee96d42d7d
2 changed files with 39 additions and 0 deletions

View file

@ -531,6 +531,13 @@ class AzureRMVirtualMachineScaleSet(AzureRMModuleBase):
differences.append('Data Disks') differences.append('Data Disks')
changed = True changed = True
if self.upgrade_policy and \
self.upgrade_policy != vmss_dict['properties']['upgradePolicy']['mode']:
self.log('CHANGED: virtual machine scale set {0} - Upgrade Policy'.format(self.name))
differences.append('Upgrade Policy')
changed = True
vmss_dict['properties']['upgradePolicy']['mode'] = self.upgrade_policy
update_tags, vmss_dict['tags'] = self.update_tags(vmss_dict.get('tags', dict())) update_tags, vmss_dict['tags'] = self.update_tags(vmss_dict.get('tags', dict()))
if update_tags: if update_tags:
differences.append('Tags') differences.append('Tags')

View file

@ -59,6 +59,38 @@
assert: assert:
that: results.changed that: results.changed
- name: Create VMSS -- test upgrade_policy idempotence
azure_rm_virtualmachine_scaleset:
resource_group: "{{ resource_group }}"
name: testVMSS{{ rpfx }}
vm_size: Standard_DS1_v2
admin_username: testuser
ssh_password_enabled: true
admin_password: "Password1234!"
capacity: 2
virtual_network_name: testVnet
subnet_name: testSubnet
upgrade_policy: Automatic
tier: Standard
managed_disk_type: Standard_LRS
os_disk_caching: ReadWrite
image:
offer: CoreOS
publisher: CoreOS
sku: Stable
version: latest
data_disks:
- lun: 0
disk_size_gb: 64
caching: ReadWrite
managed_disk_type: Standard_LRS
check_mode: yes
register: results
- name: Assert that VMSS was created
assert:
that: results.changed
- name: Retrieve scaleset facts - name: Retrieve scaleset facts
azure_rm_virtualmachine_scaleset_facts: azure_rm_virtualmachine_scaleset_facts:
resource_group: "{{ resource_group }}" resource_group: "{{ resource_group }}"