Skip to content

Commit

Permalink
updated code to fetch availability zone info into hostvars (#243)
Browse files Browse the repository at this point in the history
* updated code to fetch availability zone info into hostvars

* updated documentation part for availability_zone property

Co-authored-by: haiyuan_zhang <haiyuan.zhang1982@gmail.com>
  • Loading branch information
ShwetaliBerad and haiyuazhang authored Sep 15, 2020
1 parent 87b61e3 commit e0baca5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/inventory/azure_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
# 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'
Expand Down Expand Up @@ -538,6 +539,9 @@ def hostvars(self):
system = 'linux'
if osType == 'Windows':
system = 'windows'
av_zone = None
if 'zones' in self._vm_model:
av_zone = self._vm_model['zones']

new_hostvars = dict(
public_ipv4_addresses=[],
Expand All @@ -546,6 +550,7 @@ def hostvars(self):
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', {}),
Expand Down

0 comments on commit e0baca5

Please sign in to comment.