vm size idempotence (#45108)
This commit is contained in:
parent
55c549a832
commit
9bd702ef37
2 changed files with 32 additions and 0 deletions
|
@ -901,6 +901,13 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
|
||||||
changed = True
|
changed = True
|
||||||
vm_dict['properties']['storageProfile']['osDisk']['diskSizeGB'] = self.os_disk_size_gb
|
vm_dict['properties']['storageProfile']['osDisk']['diskSizeGB'] = self.os_disk_size_gb
|
||||||
|
|
||||||
|
if self.vm_size and \
|
||||||
|
self.vm_size != vm_dict['properties']['hardwareProfile']['vmSize']:
|
||||||
|
self.log('CHANGED: virtual machine {0} - size '.format(self.name))
|
||||||
|
differences.append('VM size')
|
||||||
|
changed = True
|
||||||
|
vm_dict['properties']['hardwareProfile']['vmSize'] = self.vm_size
|
||||||
|
|
||||||
update_tags, vm_dict['tags'] = self.update_tags(vm_dict.get('tags', dict()))
|
update_tags, vm_dict['tags'] = self.update_tags(vm_dict.get('tags', dict()))
|
||||||
if update_tags:
|
if update_tags:
|
||||||
differences.append('Tags')
|
differences.append('Tags')
|
||||||
|
|
|
@ -192,6 +192,31 @@
|
||||||
- assert:
|
- assert:
|
||||||
that: not output.changed
|
that: not output.changed
|
||||||
|
|
||||||
|
- name: Resize VM
|
||||||
|
azure_rm_virtualmachine:
|
||||||
|
resource_group: "{{ resource_group }}"
|
||||||
|
name: "{{ vm_name1 }}"
|
||||||
|
vm_size: Standard_A1
|
||||||
|
storage_account: "{{ storage_account }}"
|
||||||
|
storage_container: "{{ vm_name1 }}"
|
||||||
|
storage_blob: "{{ vm_name1 }}.vhd"
|
||||||
|
admin_username: adminuser
|
||||||
|
admin_password: Password123!
|
||||||
|
short_hostname: testvm
|
||||||
|
os_type: Linux
|
||||||
|
network_interfaces: "{{ vm_name1 }}"
|
||||||
|
image:
|
||||||
|
offer: UbuntuServer
|
||||||
|
publisher: Canonical
|
||||||
|
sku: 16.04-LTS
|
||||||
|
version: latest
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- output.changed
|
||||||
|
- output.ansible_facts.azure_vm.properties.hardwareProfile.vmSize == "Standard_A1"
|
||||||
|
|
||||||
- name: Delete VM
|
- name: Delete VM
|
||||||
azure_rm_virtualmachine:
|
azure_rm_virtualmachine:
|
||||||
resource_group: "{{ resource_group }}"
|
resource_group: "{{ resource_group }}"
|
||||||
|
|
Loading…
Reference in a new issue