diff options
author | ShwetaliBerad <shwetali.berad@gslab.com> | 2020-12-08 00:12:43 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 12:42:43 -0600 |
commit | 48d61848e930e798c0217643355677e19766926b (patch) | |
tree | 18d7f34ab1bc1a4cb68584d0322ac5ee9c64820f | |
parent | 10cc55c9089d7b0644876eb32df76c272e099b78 (diff) | |
download | ansible-48d61848e930e798c0217643355677e19766926b.tar.gz |
cherry pick for issue ansible-collections/azure#161 from ansible-collections/azure for v2.9 (#71756)
-rw-r--r-- | changelogs/fragments/161-ansible-collection-azure-inventory-fixes.yaml | 3 | ||||
-rw-r--r-- | lib/ansible/plugins/inventory/azure_rm.py | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/changelogs/fragments/161-ansible-collection-azure-inventory-fixes.yaml b/changelogs/fragments/161-ansible-collection-azure-inventory-fixes.yaml new file mode 100644 index 0000000000..ffce287c3d --- /dev/null +++ b/changelogs/fragments/161-ansible-collection-azure-inventory-fixes.yaml @@ -0,0 +1,3 @@ +bugfixes: +- azure_rm inventory plugin - update to fetch availability zone information of VM in hostvars. + (https://github.com/ansible-collections/azure/issues/161) diff --git a/lib/ansible/plugins/inventory/azure_rm.py b/lib/ansible/plugins/inventory/azure_rm.py index 245cee3a4e..219492a1e4 100644 --- a/lib/ansible/plugins/inventory/azure_rm.py +++ b/lib/ansible/plugins/inventory/azure_rm.py @@ -100,7 +100,7 @@ EXAMPLES = ''' # resource_type: the VM's resource type, eg: 'Microsoft.Compute/virtualMachine', 'Microsoft.Compute/virtualMachineScaleSets/virtualMachines' # vmid: the VM's internal SMBIOS ID, eg: '36bca69d-c365-4584-8c06-a62f4a1dc5d2' # vmss: if the VM is a member of a scaleset (vmss), a dictionary including the id and name of the parent scaleset - +# availability_zone: availability zone in which VM is deployed, eg '1','2','3' # sample 'myazuresub.azure_rm.yaml' @@ -533,6 +533,10 @@ class AzureHost(object): if 'windowsConfiguration' in self._vm_model['properties']['osProfile']: system = 'windows' + av_zone = None + if 'zones' in self._vm_model: + av_zone = self._vm_model['zones'] + new_hostvars = dict( public_ipv4_addresses=[], public_dns_hostnames=[], @@ -540,6 +544,7 @@ class AzureHost(object): id=self._vm_model['id'], location=self._vm_model['location'], name=self._vm_model['name'], + availability_zone=av_zone, powerstate=self._powerstate, provisioning_state=self._vm_model['properties']['provisioningState'].lower(), tags=self._vm_model.get('tags', {}), |