From a56a9e1eeb9796db480556903f40433fbf5a9583 Mon Sep 17 00:00:00 2001 From: MyronFanQiu <49134743+MyronFanQiu@users.noreply.github.com> Date: Wed, 29 May 2019 17:11:54 +0800 Subject: [PATCH] switch the deletion order (#57102) --- lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py index 266033df7a8..c0a1212ea4c 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_virtualmachine.py @@ -1774,9 +1774,6 @@ class AzureRMVirtualMachine(AzureRMModuleBase): except Exception as exc: self.fail("Error deleting virtual machine {0} - {1}".format(self.name, str(exc))) - if 'all' in self.remove_on_absent or 'all_autocreated' in self.remove_on_absent: - self.remove_autocreated_resources(vm.tags) - # TODO: parallelize nic, vhd, and public ip deletions with begin_deleting # TODO: best-effort to keep deleting other linked resources if we encounter an error if self.remove_on_absent.intersection(set(['all', 'virtual_storage'])): @@ -1785,6 +1782,9 @@ class AzureRMVirtualMachine(AzureRMModuleBase): self.log('Deleting managed disks') self.delete_managed_disks(managed_disk_ids) + if 'all' in self.remove_on_absent or 'all_autocreated' in self.remove_on_absent: + self.remove_autocreated_resources(vm.tags) + if self.remove_on_absent.intersection(set(['all', 'network_interfaces'])): self.log('Deleting network interfaces') for nic_dict in nic_names: