Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated code to fetch availability zone info into hostvars #243

Merged
merged 6 commits into from
Sep 15, 2020
Merged
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